Thread: How to declare a list in another list???

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    52

    How to declare a list in another list???

    Ex: I declare a function in class List:
    Code:
    void Copy(List<List<Entry>> &des,List<Entry> source);
    In using function:

    Code:
    List<int> list1;
    list1.insert(position1,item1);
    list1.insert(position2,item2);
    list1.insert(position3,item3);
    List<List<int>> listtemp;
    list2.copy(listtemp,list1);
    I want to declare a list that their entries are a list( type of integer)...
    How to declare it...when i use above declaration..compiler informs that: missing ',' before listtemp..Why?? please help me....Thanks very much....

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >List<List<int>> listtemp;
    Code:
    List<List<int> > listtemp;
    It's subtle, but notice the space between the two >'s. C++'s parsing grammar recognizes >> as the bitwise right shift operator, not two adjacent closing delimiters for nested template argument lists. You disambiguate it by separating them with whitespace.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  2. Linked List
    By jpipitone in forum C Programming
    Replies: 4
    Last Post: 03-30-2003, 09:27 PM
  3. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 05:20 PM
  4. Linked list with two class types within template.
    By SilasP in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2002, 06:13 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM