R
Rex_chaos
Hi all,
I am going to do something just like the following tell
template <class A>
class Base
{
typedef Base& ref;
public:
void show(void)
{
cout << "Base" << endl;
}
ref get(void)
{
return *this;
}
};
template <class A>
class Derive: public Base<A>
{
typedef Derive& ref;
public:
void show(void)
{
cout << "Derive" << endl;
}
};
Here, I have a "type" ref defined in the base class. It refers to the
type of the current class. I redefine the type in it's derive class
and expect the
get(void) method will return a right instance. However, it won't.
Actually, I want a function in each class to tell the type itself. How
can I do that ?
I am going to do something just like the following tell
template <class A>
class Base
{
typedef Base& ref;
public:
void show(void)
{
cout << "Base" << endl;
}
ref get(void)
{
return *this;
}
};
template <class A>
class Derive: public Base<A>
{
typedef Derive& ref;
public:
void show(void)
{
cout << "Derive" << endl;
}
};
Here, I have a "type" ref defined in the base class. It refers to the
type of the current class. I redefine the type in it's derive class
and expect the
get(void) method will return a right instance. However, it won't.
Actually, I want a function in each class to tell the type itself. How
can I do that ?