|
-
Jul 20th, 2007, 04:13 AM
#1
Thread Starter
Addicted Member
[RESOLVED] What is the purpose of ...base *bptr; bptr=new derive();
Hi All!
i have a doubt in c++,
Asume there are two classes, "Base" is a base class, "derive" is a derived class that derived from "Base".
egg:
class Base
{.....
....
};
class Derive public:Base
{
........
........
};
int main()
{
Base *bptr;
bptr=new Derive();//**** What is this meaning, and purpose?
.........
}
(a): why the object of derived class is to be assigned to base class pointer?(eventhough the derived class's object cotains both base class, and derived class's data)
(b): what the object pointer(bptr), holds?(whether it is pointing to base class or derived class)?
pls let me know the differnces between derived class object and the above mentioned bptr's content
Thanks in advance:
regards:
raghunadhs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|