I just saw a abstract class and it has a few private functions... I am just curious what's the point of private functions for an abstract class?
I assume the children will not have them. Then what's the point there?
I just saw a abstract class and it has a few private functions... I am just curious what's the point of private functions for an abstract class?
I assume the children will not have them. Then what's the point there?
As juanchopanza pointed out, there can be valid reasons for having private virtuals. But an abstract class might have a reason for having non-virtual private data as well.
Perhaps you are under the impression that an abstract class has no data members and only pure virtual functions? This is not the case. A class may have many data members and non-virtual member functions and still be abstract as long as it has at least one pure virtual member function.
class abstract_base {
public:
//functionality that derived classes must implement:
virtual int func1() = 0;
//functionality that derived classes can't override:
int get_count() const { return count_; }
private:
int count_;
};
Maybe a silly example, but you get the idea.