Solved

Remove inherited method?

Posted on 2009-04-11
3
376 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
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
Comment Utility
>>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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
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.

763 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

12 Experts available now in Live!

Get 1:1 Help Now