Solved

Remove inherited method?

Posted on 2009-04-11
3
387 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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