Thread: simple template friend question

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    27

    simple template friend question

    Here is the top of my class

    Code:
    template < class T >
    class TODLLNode
    {
      friend class TODLList;
    Whenever I try to intialize anything in a test function I get the error

    todllnode.templ:16: error: template argument required for 'struct TODLList'

    What am I doing wrong?

    If it helps...

    My private variables are as follows:

    private:
    T data_;
    TODLLNode < T > * fore_;
    TODLLNode < T > * back_;



    Here is a simple initializing of a variable to get this error in my test function

    TODLLNode < int > a;
    Last edited by noodle24; 06-02-2006 at 11:40 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Why not post the smallest and simplest piece of code that demonstrates the error?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Unless I miss my guess TODLList is a template and you'll want to make
    Code:
    friend class TODLList;
    ->
    Code:
    friend class TODLList<T>;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  2. friend question
    By black in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2004, 05:55 AM
  3. Template Question
    By Eber Kain in forum C++ Programming
    Replies: 5
    Last Post: 06-12-2004, 10:07 PM
  4. function template question
    By Thantos in forum C++ Programming
    Replies: 3
    Last Post: 04-18-2004, 10:40 AM
  5. question about .net to 6.0 change causing errors
    By jverkoey in forum C++ Programming
    Replies: 17
    Last Post: 03-23-2004, 10:45 AM