- 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
112 Posted Topics
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 … | |
Re: What language is the main app written in? Presumably C++/MFC, so it makes sense to go with MFC for the DLL. You don't say which version of Visual Studio you are using, but in general to create an MFC DLL, create a new project, select C++/MFC/MFC DLL. Then you'll need … | |
Re: Well I thought I made it fairly clear in your previous thread TBH. [QUOTE]The timer doesn't work without the paint code in MyTimerFunc() because you don't handle WM_PAINT, so the window is not validated and the high frequency (and priority) of WM_PAINT messages blocks the low priority WM_TIMER message. Just … | |
Re: What is the event() you are waiting for? Presumably this event is being seen by both processes. If you are talking about a windows synchronisation event, these can be accessed by more than one process (depending on the creation method). | |
Re: In main thread: When you handle the close event send a message to the worker thread requesting termination. Then use WaitForSingleObject() on the worker thread handle to wait for thread termination. In the worker thread: Handle your termination message and stop the thread. | |
Re: I suspect that you are changing the current working directory without realising it. Try experimenting a bit to see what it is you are doing before you call _getcwd() which might be changing it. | |
Re: [QUOTE=_Nestor;864666]The probem is that you have to see seed the random generator with the srand function[/QUOTE] The OPs code is seeding it. Though I do wonder about the code the OP used to generate that output. How close was it to the code actually posted? Was srand(time(0)) being called before … | |
Re: The key to this is the format of your text file. It's a unicode text file which needs special treatment on input. So the next question is - have you been provided with this specific file which you must be able to read or did you create it yourself? Hopefully … | |
Re: Using BeginPaint() ad-hoc like this isn't recommended. Works sometimes, but isn't reliable. You should only use it in response to WM_PAINT messages. Your WM_PAINT handler does nothing, so I suggest you add something like this to MainWndProc():- [code=cpp] case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(hwndMainFrame, &ps); // … | |
Re: As somevar is declared in main() you can't refer to it in build(). You are passing it into build() with the name othervar, so if you replace somevar by othervar in build() you will be able to compile. Other points to note: Given this forum, I'm assuming this code is … | |
Re: The auto_ptr copy constructor (which you are calling each time you return my_player) only allows a non-const parameter because it needs to clear the pointer from the source after moving it to the destination. All of your functions are declared const, so the appropriate copy constructor (i.e. one which copies … | |
Re: As your compiler indicates that you're calling TextOutW(), the unicode version of TextOut(), it appears that you have set an option in your project to compile for unicode (or it was the default). The problem this gives you is that char buffer[80] is not suitable for a unicode string. Casting … | |
Re: There are no language constructs to get the address of an object from the address of a member. Your compiler will manage the memory in the class as it sees fit so unless you want to get down and dirty with your compiler, which I'm not recommending, you can't do … | |
Re: [QUOTE=siddhant3s;854692]>>Why didn't the C++ standard also have the delete operator reset ptr to NULL? First of all you are simply **NO ONE** to ask question like this. C++ standards have been made by the most proficient and experienced programmers of this language. If you think there should be a feature … | |
Re: One obvious reason for the error is that 'value' contains a string which, when converted to hex, generates more than 2 digits and a zero terminator. In this case it would exceed your 3 character allocation. I presume you've checked that this isn't happening? | |
Re: I'm not sure why you are considering recursion for this problem. It's not appropriate here. What about simplifying your algorithm: [code=cpp] int dayNum1 = getDayNumber(date1); int dayNum2 = getDayNumber(date2); int dayDiff; if (dayNum1 > dayNum2) { dayDiff = dayNum1 - dayNum2; } else { dayDiff = dayNum2 - dayNum1; } … | |
Re: You want a control derived from ComboBox which provides auto-completion. Take a look at this example: [URL="http://www.freevbcode.com/ShowCode.asp?ID=7007"]http://www.freevbcode.com/ShowCode.asp?ID=7007[/URL] | |
Re: Hard to be specific as you don't say whether you are using .NET, MFC or the Windows Api. You need to modify the Visibility style of the control to make it disappear/reappear. To make it temporary you will have to manage the delay yourself. .Make control invisible .Start timer .Handle … | |
Re: Are you absolutely sure "example.txt" isn't already open in another application? | |
Re: Try calling: mysql_query(connection, sql.c_str()); sql.c_str() will provide the conversion to const char*. | |
Re: [QUOTE=luutu_amir;853898]1 write aprogram toread student's name examination number ,score for six subjects plus their average score using type one of c++ please i need this 30 minutes 2 using c++ write aprogram compute the number of students in a room (classes)[/QUOTE] I can do the second one: [code=cpp] int main( … |
The End.