[Solved] How do I inherit only the member functions in C++?


having attribute of a base class that is not needed in derived class is a hint for bad inheritance

in your case i assume you are going to have another derived class that needs those data members, otherwise it wouldnt make sense

then why not do something like this:

class Base
{
public:
    void f1(void);
    ...
};

class DerivedClass : Base
{
... add stuff here that's unique to Derived
};

class DerivedClass2 : Base
{ 
     public:
         int data1;
         ....
}

if you have more derived classes that needs those data member i suggest you to make separate base class, one for functions and one for data members.

solved How do I inherit only the member functions in C++?