Thread: Include(#directive) problems

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    20

    Include(#directive) problems

    I've looked over the code and everything looks fine. It won't compile though.

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    ok..these are some of the big mistakes programmers make..since you are doing a template class..you gotta remember the rules..look at this example

    Code:
    template<class t>
    Something
    {
    public:
    Something();
    
    int sum(int x, int y); // a member function prototype
    private:
    t value;
    };
    
    //now in the cpp file
    template<class t>
    Something<t>::Something()
    {
    //does nothing
    }
    
    template<class t>
    int Something<t>::sum(int x, int y)
    {
    return x+y;
    };
    when you are writing the functions definitions outside the class definition you have to keep putting your 'template<class t>' and when you get to the scope resolution operator for your class like
    Something:: you have to put 'returntype Something<t>::functionname' over and over and over..so the compiler knows it a template class...that is all
    nextus, the samurai warrior

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  4. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  5. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM