Thread: Classes Using Templates

  1. #16
    *this
    Join Date
    Mar 2005
    Posts
    498
    Dude, someone already provided a way to do that, which I echoed in the last post:
    Ya I know I was asking about the code I provided because in the past I've tried the code and ended up putting it in the class etc...

    I wasn't necessarily asking about a templated array, because there are other reasons to have a templated class.
    Last edited by JoshR; 07-14-2005 at 07:50 PM.

  2. #17
    *this
    Join Date
    Mar 2005
    Posts
    498
    Also Dae that example you claimed to "be the solution" doesn't compile:

    Untitled1.cpp:13: error: non-template type `Array' used as a template
    Untitled1.cpp:14: error: ISO C++ forbids declaration of `Array' with no type

  3. #18
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Code:
    template <class Datatype> class Array
    {
    //code
    };

  4. #19
    *this
    Join Date
    Mar 2005
    Posts
    498
    Thanks, thats their fault for not posting correct code: I assumed you took that off because it's not in the code...

  5. #20
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by JoshR
    Thanks, thats their fault for not posting correct code: I assumed you took that off because it's not in the code...
    Actually it is the right code.

    You forgot to declare the actual class as a template too.. which I did in the original post so it wasnt necessary to repost that part. We were talking about seperating the methods from the templated class, which you apparently did not have templated according to your error.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulating Templates or Classes in C
    By algatt in forum C Programming
    Replies: 1
    Last Post: 04-09-2007, 02:12 PM
  2. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  3. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  4. VC++6: exporting classes containing templates
    By ttt in forum Windows Programming
    Replies: 2
    Last Post: 09-15-2003, 11:38 AM