John Distai
November 21st, 2000, 01:34 PM
Hi. I am using a Teach Yourself Visual C++ 4.0 in 21 Days book to learn Visual C++ 4.0. I can program the first lesson, but any subsequent lesson does not work. Each lesson requires an "Exit" button. When you program the "Exit" button, you add code that says "OnOk();". On the first program, when the button is clicked the program exits. After the first program, it doesn't work unless I program the "Exit" button before I program anything else. When I compile I receive an error like "OnOk() is undefined". Isn't OnOk() a standard function? I would appreciate any help in getting past this so I can continue learning. I am using MS VC++ 4.0 in Windows 98.
Thanks!
nikb
November 22nd, 2000, 06:22 AM
Hello,
First of all, this is not the correct forum for your issued. It is the "Bugs and Fixes" forum, dealing with potential bugs. You should probably post in the "Visual C++ Programming" forum. Anyways, don't worry too much about it. I merely pointed it out so you would avoid the mistake in the future, and help you get faster answers.
Do you have "OnOK" defined in the header file in your class?
OnOK() is declared in the base class, but you must also declare it in the header file for the derived class:class CMyDialog : public CDialog
{ // this is a derived class, on top of CDialog
...
virtual void OnOK();
...
};
Also, I noted that you're referring to it as "OnOk" which might very well be your problem.
C++ like C is CaSe SeNsItIvE, which means that "OnOk" is very different than "OnOK".
I hope you enjoy learning!
-n