Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

mutable base class

In the case of multiple inheritance

class A{
...
};

class B{
...
};

class C:
 public A,
 public B{

 int func()const;
};


I wish func to be able to change data members derived via class A but not those derived via class B.

I would like to say

class C:
 mutable public A,
 public B{

but this is illegal.

What is the best solution which achieves what I want?
0
glebspy
Asked:
glebspy
1 Solution
 
thienpnguyenCommented:
class C : pulbic B
{
    mutable A a;
   int func()const;
};

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now