A
Armin Zingler
Hi,
sorry for this C++ noob question... I'm coming from VB.Net actually and I
am trying to do the same in C++ (/CLR) as I do here (pseudo code partial):
class C
implements I1
implements I2
private sub I1_f1() implements I1.f1
end sub
private sub I2_f1(args) implements I2.f1
end sub
public sub M1
end sub
public sub M2()
end sub
end class
So, in VB.Net it is possible to write an object that has 3 different
(inter)faces:
a) class ("Dim o As C"): public methods M1, M2
b) implementing interface I1 ("Dim o as I1 = New C"): method f1 implemented
by I1_f1
c) implementing interface I2 ("Dim o as I2 = New C"): method f1 implemented
by I2_f1
For me it is especially very important to consider each of the three as an
independent and individual context. A reference of type C is a different
context(/contract) than a reference of type I1 or than type I2, even if all
references reference the same object.
I haven't figured out how to realize the same in C++. It seems, the "wiring"
of interface members to class members is only done by the member name. As a
consequence, the independence is lost. Therefore, I don't know how to write
different implementations for function f1 that only happens to have the same
name in both interfaces but might have a completely different meaning. I
also don't know how to avoid that a function implementing an interface is
added to the "class interface" (a reference of type C).
I hope you can help me with this or just tell me that it is not possible.
Thanks in advance.
Armin
sorry for this C++ noob question... I'm coming from VB.Net actually and I
am trying to do the same in C++ (/CLR) as I do here (pseudo code partial):
class C
implements I1
implements I2
private sub I1_f1() implements I1.f1
end sub
private sub I2_f1(args) implements I2.f1
end sub
public sub M1
end sub
public sub M2()
end sub
end class
So, in VB.Net it is possible to write an object that has 3 different
(inter)faces:
a) class ("Dim o As C"): public methods M1, M2
b) implementing interface I1 ("Dim o as I1 = New C"): method f1 implemented
by I1_f1
c) implementing interface I2 ("Dim o as I2 = New C"): method f1 implemented
by I2_f1
For me it is especially very important to consider each of the three as an
independent and individual context. A reference of type C is a different
context(/contract) than a reference of type I1 or than type I2, even if all
references reference the same object.
I haven't figured out how to realize the same in C++. It seems, the "wiring"
of interface members to class members is only done by the member name. As a
consequence, the independence is lost. Therefore, I don't know how to write
different implementations for function f1 that only happens to have the same
name in both interfaces but might have a completely different meaning. I
also don't know how to avoid that a function implementing an interface is
added to the "class interface" (a reference of type C).
I hope you can help me with this or just tell me that it is not possible.
Thanks in advance.
Armin