What error is generated ? Please, when you have errors, crashes and things like try to be as complete as possible. This will help people to understand better your problem.
vikas amin wrote:
use a Base ptr to point to Derived Object
It is not the case in your sample code. In your code, you just use the base class.
vikas amin wrote:
class Derived: public Base ,virtual temp
Also, what has this virutal temp to do there ?
If you are using a base pointer that has been allocated as an derived class (Base* ptr = new Derived;), if you don't specify that your destructor is virtual, then only the destructor of your base class will be called thus this may result in memory leaks (and other problem if you have specific clean-up code in the destructor of your Derived class)
so when deived class is instantiated,first base class constuctor will be called then the derived.llarly when the memory allocated to derived object gets cleaned up the reverse should takes place first the destructor of derived must be called and then base destructor.
so if cleaning takes place via base pointer the destructor must be made virtual.
but i suggest u to always make base destructor virtual if u want to derive class form the base class
I am creating the installer package for MFC app with InstallShield. Now I want while installing the user should not be able to select the subfeatures twice in the Customed installation. He should be able to select the sub feature only once. for the second time he will not be allowed. How can i do that?
Doing so allows you to write object oriented code and at runtime can easily manage the state of the window because you can always retreive the object associated with the window using the GWL_USERDATA given the window handle.
It is a little bit tricky to explain. First important point: the window procedure has to be static because static member functions and standard member functions behave differently (and don't have the same prototype). Standard member functions are kind of 'attached' to an instance of your class (so when they are called they 'know' to which instance they belong). In fact this is done by passing an additional parameter to your function, which the this parameter of the instance (and thus the pointer to the instance). This is done implicitely and the user doesn't know about it (it's hidden).
Now if you take a static member function, the behavior is different: for a static member function, it is shared among all instances of the class and thus, doesn't belong to any particular instance of the class. This has two consequences: first, there is no need for the implicit 'this' parameter (because the function doesn't blong to an instance) and second, the function doesn't have access to data from a particular instance: in a static function, you cannot access non-static member, you can only access to static member variables and functions (which are then shared among all instances).
For the windows procedure, it accept only a certain type of functions prototypes which are not member functions, thus the only way to have it in your class is to declare it static. The consequence is that it doesn't which instance it belongs to, so the need to 'save' first the this parameter associated with the specific window handle. This will allow you to get the 'this' parameter later and to be able to call the non-static window procedure of a particular instance.
Hope this helps, if you need some more precisions, don't hesitate to ask
I am creating one mdi application, which has say 5 forms(like employee management, leave management, etc.). these forms are derived from CFormView. What i want is if user clicks one of 5 menus the corresponding form should be shown as child window. I want know how to create an instance for these forms. How to make this for as a child window and how to show it? that is my problem.
I would like to develop a Remote Task Manager utility, which reads the Tasks running on a remote machine(s). Does anybody give me a hint, how it can be done in C++/MFC.
Thanks in Advance