- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 11
- Posts with Upvotes
- 11
- Upvoting Members
- 11
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: The important difference with assert() is that it doesn't affect production (release build) code. So all those checks don't affect performance, and as the code is debugged by then, you don't need them right? (yeah right). For debugging I find assert() much better than exit(0) as it leaves the debugger … | |
Re: [QUOTE=Kadence;931160] I also couldn't find any references or docs online for GetAKeySyncState(), and when I try to compile (after including windows.h) on my Windows machine I get[/QUOTE] In Win32 it's GetAsyncKeyState() or GetKeyState(). | |
Re: I'm not sure I understand it either, but I don't think it's win32 because MFC is in the title, and I don't think the problem is one of adding error checking, rather it's to remove it. If you don't want to see an error message when the input is invalid … | |
Re: More info will be required for a response. What environment are you working in - Unix,PC,.Net,MFC etc. | |
Re: I think you should check out the [URL="http://sourcemaking.com/design_patterns/command"]Command pattern[/URL]. In your case this means adding an Execute() method to your BaseEvent class. In the derived event classes you will code the Execute() method to call a virtual method in the Module class. You send the Event (Command) to a Module … | |
Re: I've barely glanced at that code but stack overflow in a binary tree application is likely to be a recursion error. i.e. one of your methods is calling itself (which is fine) but the exit condition which stops it calling itself is never being reached. See if you can find … | |
Re: myStack:top and myStack:push take a Stack_entry argument, not a char which you are calling them with. Given that Stack_entry is typedefed to char that links fine in my VS2005 environment, but VS2008 may have tightened up on that. Try calling those methods with true Stack_entry types. | |
Re: Without seeing the rest of this class (e.g. constructor/destructor) it's not possible to give a full answer to your problem. However, explicitly calling destructors on your local variables is a bad idea. The destructor will be called again when it goes out of scope. The point at which it crashes … | |
Re: [QUOTE=kevintse;1187626] I just have no idea why Bjarne Stroustrup states that "In particular, declaring data members protected is usually a design error.". [/QUOTE] I think you do - he tells you his exact reasons in the extract you quoted. You could have a number of derived classes in your application … | |
Re: A bit more info may be required. Are you using MFC or .NET with C++? If MFC, are you using CTabCtrl? I've no idea what level you're at but in simple terms you create a button click handler, inside which you: - query the tab control to find out the … | |
Re: You're right to stop where you are until you've sorted out the design. This approach you've taken so far is going to be painful. So, think about inheritance. Do your classes pass the basic test - i.e. PassengerMenu 'is a' MainMenu? No they don't. Your MainMenu is a specific menu … | |
Re: Narue's reply from the C++ forum is still applicable. i.e. the text property returns a string so you need to convert it to an integer before the compare. | |
Re: There's no simple property on the ListView which will give that functionality. It would probably be easier to use the DGV but if you really don't want to do that, you could enhance the ListView to get the behaviour you're after. 1. You would have to detect mouse clicks on … | |
Re: I've always found AfxExtractSubString() to be useful for that kind of thing. Not a particularly well documented function but it's there and it works. [CODE=cpp] BOOL AFXAPI AfxExtractSubString ( CString& rString, LPCTSTR lpszFullString, int iSubString, TCHAR chSep = '\n' );[/CODE] e.g. set lpszFullString to "Condition1|condition2|Condition3", set chSep to '|' set … | |
Re: As the compiler tells you, your problem is that the return statement in rotationX is creating a temporary fourMatrix value for which you are trying to return a reference. Returning a reference to a temporary variable is meaningless since it will refer to nothing when the method is complete. Your … | |
Re: So, just to clarify, the compiler indicates that DoubleMonsters is not declared? Can you post the class definition for DoubleMonsters? | |
Re: It looks like you're using managed C++, so try using: [CODE]using namespace System::Threading; Thread::Sleep(1000);[/CODE] I'm surprised that you find plain old Sleep() available, so perhaps you're picking up an odd version of Sleep from somewhere in your codebase. | |
Re: Double check that your implementation of OnCtlColor is returning a handle to the brush you want to set the background colour. | |
Re: Did you override OnInitDialog() in your dialog? If so, try simplifying it or step through it. A serious error here could reset the WF_CONTINUEMODAL flag and cause the dialog to exit. | |
Re: [QUOTE=AceiferMaximus;989032]Is it possible to call a .dll I made in C#, and use it in my unmanaged C++ code? [/QUOTE] It's certainly possible, though you may want to go via some managed C++ to get there. By compiling some of the modules in your C++ project with the /clr switch … | |
Re: Frederick2 may well be right, though I would also look at more basic issues. Getting an hour glass cursor using MFC is generally a simple case of declaring: CWaitCursor myWaitCursor; inside a method. The wait cursor is then displayed for the duration of that method. It is removed when the … | |
Re: To test the string for non-numerics - loop through the string and call standard library function isdigit() on each character. To convert to the array - loop through the (numeric) string, for each character subtract '0' and put the result in the corresponding element of the array. | |
Re: If val = 0x11223344 then that expression will 'or' the following [CODE] FF000000 3344 223344 11223344 [/CODE] So the top byte is always FF. The bottom byte is always the bottom byte of val and the 2 middle bytes are an 'or'ed set of some of the val bytes. That's … | |
Re: [QUOTE=JasonHippy;952634]What about if you change px from int to long? Does that give you any differemt results? The thing to take note of here is that px is currently declared as an int. Whereas rect.right and rect.left are both LONG/long variables. Therefore if the result of your calculation is less … | |
Re: [QUOTE=slatk3y;934064]ok, so that make sense. Thanks. I have another question now. I am trying to set a bit in unsigned, that is what I am doing: [code=C++] #include <iostream> using namespace std; int main(){ unsigned i = 0; unsigned index = 1; i >> (31 - index) |= 1; } … | |
Re: If you don't want to end the loop on a sentinel, what about asking the user for a student count before you get the student record data. Remember to check that it's less than the size of your array. Then change your loop so that it's based on your count. | |
Re: [QUOTE=niek_e;928090]Although Adatapost's solution will compile and work, there's no reason why you should use this (ever).[/QUOTE] Well Adatapost's specific example doesn't achieve much but there's still a reason to do that. e.g. in constructing a temporary object to pass to a function:- [CODE=c++] class Point { Point(int x1, int y1){x … | |
Re: If you haven't done it, make sure you also change: WS_CHILDWINDOW || WS_CLIPSIBLINGS ||WS_CLIPCHILDREN to WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | |
Re: int dummyArray[size] declares an array of a fixed size. 'size' must be a constant known at compile time. e.g. int dummyArray[5] would work as the compiler knows how much space to allocate. So your way out of this is: 1. Declare an array large enough to handle your largest expected … | |
Re: If you're just counting down from 10 to 0 I'm not exactly sure why you've used 2 loops. Surely a single loop would do the job. I do notice that the inner loop won't terminate because your condition (units < 10) is incorrect. units is counting down and will always … |