Thomas Kowalski wrote:
Hi everyone,
following situation:
class A
{
void m(T value) =0;
}
I guess you probably want the following:
class T;
class A
{
public:
virtual void m(T value) = 0;
};
Note that:
1. Type T is declared before it is used.
2. Member function m() is now a public member.
3. m() is also made virtual. Otherwise the "=0" is just an utter error.
4. The class definition ends with a semicolon.
>
class B : A
{
void m(TA value);
void m(TB value);
}
Again, I guess you want the following:
class TA;
class TB;
class B: public A
{
public:
void m(TA value);
void m(TB value);
};
>
class T
{
}
class TA : T
{
}
class TB : T
{
}
Reminder: Both TA and TB privately inherits from T, and all three
classes need semicolon to end with.
>
The original methode A::m(T) is not overriden, just hidden by B::m. Is
B an "abstract" class and have to overwrite m(T) specificly? Can a
methode call like this be resolved like expected according to the
C++Spec:
Class A is abstract, it declares a pure virtual member function. Unless
class B explicitly implements the pure virtual member function A::m, it
remains abstract.
B b;
TA ta;
b.m(ta);
Technically, if B is abstract then you can't instantiate an object of
type B, so never mind what happens to the object.
On the other hand if you make B non-abstract by supplying an
implementation of A::m in B, e.g.
class B: public A
{
public:
void m(T);
void m(TA);
void m(TB);
};
then overload resolution will guarantee the right overload gets invoked.
>
Thanks in advance,
Thomas Kowalski
Ben