Solved

mutable base class

Posted on 2001-09-08
1
244 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

760 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

19 Experts available now in Live!

Get 1:1 Help Now