Solved

Remove inherited method?

Posted on 2009-04-11
3
385 Views
Last Modified: 2013-12-14
Hello,

My C++ is a little rusty but I believe that I cannot  mark an inherited virtual method as "ignore" or "remove" or "delete" so it is not available to subclasses.  In the past, I simply "override" the method in the subclass and threw an Exception that indicated that this method was not available to the subclass.  Is there a better way to handle this situation?

Oh!  In case it matters... I am using the latest version of MSVS C++ CLI.

Thanks for your help,
Mike
0
Comment
Question by:mjgardne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
ID: 24123888
>>My C++ is a little rusty but I believe that I cannot  mark an inherited virtual
>>method as "ignore" or "remove" or "delete" so it is not available to
>>subclasses.

Make it 'private'. Methods declared in the 'private' section of a class are not accessible from derived classes.
0
 
LVL 6

Assisted Solution

by:peter41
peter41 earned 100 total points
ID: 24124654
If methods which you want to hide must stay public in base class,
you can leave them 'public' and make 'private' inheritance, for example:
class CBaseClass
{
public:
...
}
class CNewClass : private CBaseClass
{
...
}
 Thus public methods in base class will not stay public in derived class.
0
 

Author Closing Comment

by:mjgardne
ID: 31569237
Geez!  I was lost in the details and missed the obvious!  Thanks, Guys!  I tagged the methods as private, et voila, the subclasses don't see them.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

749 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