473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HOW CAN I invoke method through the middle class in the inherit hiberarchy?

class Base1 { public virtual func() ... }
class Base2 : Base1 { public override func() ... }
// i already have two class Base2 inherit Base1;
//and want to inovke Base1::func(),but not Base2::func();
class Base3 : Base2 {
public override func()
{
// i want invoke Base1::func();
// how can i do?
}
}
Nov 14 '09 #1
3 1372
Curtis Rutland
3,256 Expert 2GB
This looks like C++, so I'm not entirely sure. In C# it would be something like
Expand|Select|Wrap|Line Numbers
  1. base.base.func();
So maybe in C++ it would be
Expand|Select|Wrap|Line Numbers
  1. base::base::func()
I'm not sure as I've never worked with Visual C++.
Nov 16 '09 #2
Plater
7,872 Expert 4TB
base.base throws compiler errors for me. base seems to only go up ONE level for me and no way to go up further?
As for the original problem, I think you need to use different function names?

You might be able to do something as a type cast though?

Don't use virtual, use new keywords instead, observe:


Expand|Select|Wrap|Line Numbers
  1. public class base1 
  2.     {
  3.         public void func()
  4.         {
  5.             MessageBox.Show("base1"); 
  6.         }
  7.     }
  8.     public class base2 : base1
  9.     {
  10.         public new void func()
  11.         {
  12.             MessageBox.Show("base2");
  13.         }
  14.     }
  15.     public class base3 : base2
  16.     {
  17.         public new void func()
  18.         {
  19.             base.func(); //shows "base2"
  20.             base1 o = (base1)this;
  21.             o.func(); //shows "base1"
  22.         }
  23.     }
  24.  
Then this call will verify it:
Expand|Select|Wrap|Line Numbers
  1. base3 f = new base3();
  2. f.func(); 
  3.  
Nov 16 '09 #3
Curtis Rutland
3,256 Expert 2GB
I admit I was just guessing. I've never had to do that.
Nov 16 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Simon King | last post by:
I have created a service which uses the FileSystemWatcher to monitor folders for file changes. I have a app.config file which specifies which folders to watch and what to do when a change occurs. ...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
3
by: Max | last post by:
I want to do something like this in the user control: Call myParentPage.BindSQL() BindSQL is a sub on the parent page. This user control will be used on multiple pages. Perhaps this is not a...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i donīt want to filter the return value of the method, i have to pass a new instance of the...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
0
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be...
0
by: Keith | last post by:
I have a web form that contains a repeater control that is designed to ask like a check book register. Clicking on a certain transaction takes the user to a different .aspx page where it can be...
6
by: Dom | last post by:
I'm teaching myself about delegates and the Invoke method, and I have a few newbie questions for the gurus out there: Here are some CSharp statements: 1. public delegate void MyDelegate (int k,...
3
balabaster
by: balabaster | last post by:
I have a class that I want to make thread-safe and am investigating the ISyncronizeInvoke interface and wondering just what it will take to implement this interface. So far the basic concept of my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.