Solved

mutable base class

Posted on 2001-09-08
1
256 Views
Last Modified: 2012-06-27
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
Comment
Question by:glebspy
1 Comment
 
LVL 6

Accepted Solution

by:
thienpnguyen earned 50 total points
ID: 6467466
class C : pulbic B
{
    mutable A a;
   int func()const;
};

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now