Click to See Complete Forum and Search --> : type restriction and inheritance : please please help me!


crou
May 29th, 2002, 11:51 AM
First of all, I apologize in advance for my poor english.

Here is my problem :

I use two template classes : Container and Array which is derived from Container.

Container can contain absolutely anything and Array, which is more specific, should be used only with simple type (float, short, etc...)

However, I need to use Array with more elaborate types such as CPoint

When I try, I have a message such as :

undefined reference to `CArray<CPoint>::CArray(int, int)'

How is that possible?
Is it possible to restrict the Type when a class derives from another?

Any help will be welcome
Thank you in advance

croucrou

Bob Davis
May 29th, 2002, 12:01 PM
It may help if you could post the interface and implementation files for the Container and Array classes, so we can see what you've got so far.

crou
May 30th, 2002, 03:14 AM
As I said before, CContainer is able to contain absolutely anything

For instance, I built a class called temp:


template <class Type> class temp : public CContainer<Type>
{ };

void main(void)
{
CContainer<CPoint> f(3, 4);
temp<CPoint> g(3,4);
}





and the compiler tell me

no matching function for call to `temp<CPoint>::temp (int, int)'

but there are no errors for the construction of the CContainer<CPoint>

How is that possible?