Base class pointer to derived class object???
-
what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.
-
what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.
In this instance, none. However, if you have many different derived classes, you can create a collection of the base class to hold them all, and if the base class defines a generic interface, an instance of the base class can do many things, depending on what derived class the instance is. This question is in the wrong forum, BTW. This is for .NET questions only.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.