|
-
May 29th, 2002, 11:51 AM
#1
type restriction and inheritance : please please help me!
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
-
May 29th, 2002, 12:01 PM
#2
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.
-
May 30th, 2002, 03:14 AM
#3
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|