Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 575101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:54:06+00:00 2026-05-13T13:54:06+00:00

I have been reading an article about C++ interfaces ( http://accu.org/index.php/journals/233 ) and I

  • 0

I have been reading an article about C++ interfaces (http://accu.org/index.php/journals/233) and I am completely lost at the part where it says all the virtual member functions should be made private (the section titled “Strengthening the Separation”). It just does not make sense to me at all.

According to the author, the code is 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;
  //...
};

class line : public shape {
public:
  line(point end_point_1, point end_point_2);
  //...
private:
  virtual ~line();
  virtual void move_x(distance x);
  virtual void move_y(distance y);
  virtual void rotate(angle rotation);
  //...
};

So we have a pure virtual function which is public, and its implementation (in the line class) which is private.

Could anybody explain how the move_x function can be called? Its access specifier is private, it will lead to an error if I try to do this:

line my_line(point(0,0), point(1,2));
my_line.move_x(-1); // does not compile

Similarly is it correct to say that the drawing interface (see earlier in the article)cannot access these functions either?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:54:06+00:00Added an answer on May 13, 2026 at 1:54 pm

    The idea is that you’d use those methods via a reference or pointer to shape.

    shape &s = my_line;
    s.move_x(-1);
    

    This could be justified on the grounds of “reveal only what you need to”, or as a form of self-documentation. It proves that the methods are only called in the intended way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading an article about Lockless Programming in MSDN. It says :
i have been reading this interesting article which is increasing my every growing confusion
Have been reading about async and tasks and been attempting to convert the CopyFileEx
I have been reading about making ajax heavy applications more search engine friendly: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
I have been reading a lot about HTML 5 and some of the changes
I have been reading a lot about Double Buffering as I am working on
I have been reading countless articles about how to architect a new MVC 3
I have been reading Wikipedia's article on K programming language and this is what
I've been reading up a bit on how multi-tiered commenting systems are built: http://articles.sitepoint.com/article/hierarchical-data-database/2
So lately I've been reading a lot of article about how concurrent programming is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.