I read an article about C ++ interfaces ( http://accu.org/index.php/journals/233 ), and I'm completely lost in the part where it says that all virtual member functions should be private (section "Strengthening separation "). It just doesn't make sense to me at all.
According to the author, the code looks like this:
class shape { public: virtual ~shape(); virtual void move_x(distance x) = 0; virtual void move_y(distance y) = 0; virtual void rotate(angle rotation) = 0;
So, we have a pure virtual function, which is publicly available, and its implementation (in the string class), which is private.
Can anyone explain how the function move_x can be called? Its access specifier is private, this will result in an error if I try to do this:
line my_line(point(0,0), point(1,2)); my_line.move_x(-1);
Is it also fair to say that the drawing interface (see earlier in the article) cannot access these functions?
Thanks.
c ++ class interface
Andy
source share