LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

A CPP question

hi all, I know - this isn't the correct forum to talk about C++. But I got often good tips here also regarding this thema. The simple question: The derive-order of my classes may be: interfaceClass otherClass:interfaceClass lastClass:otherClass -->built the "interfaceClass"-class by building in a pure virtual functions ("virtual void fct()=0"). -->in the downward-order of derived classes from this "interface" I have to implement this function into the derived classes - thats clear. and so "otherClass" has to implement its own version of fct() -->now I want to have a class "lastClass" that shall not have an own implementation of this function. it should use the fct() of "otherClass". -->in JAVA you can say "super.fct()", in C# "base.fct()" but how to do this in CPP ? Is this possible and how to realize ? thanks and best regards Simon
0 Kudos
Message 1 of 4
(3,228 Views)
Is otherClass::fct(); what you are looking for?
 
JR
0 Kudos
Message 2 of 4
(3,207 Views)
jr,

no, if I do this the compiler wants to call a static-function. but it is a normal function of the base-class to call about an instance-pointer.

also a type-cast of the this-pointer into a base-class-pointer doesnt help, because the function is a virtual one.

******************

In detail there are two problems:

1. I realize an abstract class ("interface") by builing a pure virtual function into this class. if I derive a second-generation-class from this interface, I have to implement the method - ok, thats the cause we use interfaces.

now I want to derive a class in a third generation. and this should use the always implemented function of the second-generation-class.
but I have to implement the method ones more into this third-generation-class - says the VC-Compiler.

Why this?

2. A possiblity to workarround this could be to implement the method into the third-generation-class and call there the method of the second-generation-class. but I dont find a possibility to do this in C++ - we talked about this.

Any idea?

Best regards

Simon
0 Kudos
Message 3 of 4
(3,180 Views)
just to close this thread:

it is also possible a class inherits a interface-method from a base-class. i had done something wrong in my class-modell.

sorry

james
0 Kudos
Message 4 of 4
(3,111 Views)