KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class B with a set of constructors and an assignment operator. Here it is: class B { public: B(); B(const string& s); B(const B& b) { (*this) = b; } B& operator=(const B & b); private: virtual void foo(); // and other private member variables and functions }; I want to create an inheriting class D that will just override the function foo() , and no other change is required. But, I want D to have the same set of constructors, including copy constructor and assignment operator as B : D(const D& d) { (*this) = d; } D& operator=(const D& d); Do I have to rewrite all of them in D , or is there a way to use B 's constructors and operator? I would especially want to avoid rewriting the assignment operator because it has to access all of B 's private member variables.
Tags (comma-separated)
Save Edits
Cancel