|
-
July 24th, 2014, 11:49 AM
#1
How to clone an object in C++?
I define two classes in C++, as follows:
class CBaseClass
{
…
}
class CDerivedClass : public CBaseClass
{
…
}
And want to implement a clone function as follows:
CBaseClass *Clone(const CBaseClass *pObject)
{
}
When an object of CDerivedClass is passed to Clone, then the function will also create a CDerivedClass object and return.
When an object of CBaseClass is passed to Clone, then the function will also create a CBaseClass object and return.
How to implement such a feature?
Tags for this Thread
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
|