CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Location
    grenoble, france
    Posts
    5

    Unhappy 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

  2. #2
    Join Date
    Jan 2001
    Posts
    588
    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.

  3. #3
    Join Date
    May 2002
    Location
    grenoble, france
    Posts
    5

    Cool

    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
  •  





Click Here to Expand Forum to Full Width

Featured