compiler error

This is a discussion on compiler error within the C++ Programming forums, part of the General Programming Boards category; Ok I know this has to be a quick fix- which will make me feel awful but I can't get ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    17

    compiler error

    Ok I know this has to be a quick fix- which will make me feel awful but I can't get this progam to run because WriteList is not a member of list. Am I putting the wrong info in, am I putting it in the wrong place??? Am I forgetting to #include something???

    Code:
    #include<iostream>
    #include<string>
    #include<list>
    
    
    using namespace std;
    
    
    	template<class T>
    	void WriteList(list<T> S){
    		list<T>::iterator iter;
    
    	for(iter=S.begin();iter!=S.end();iter++){
    		cout << *iter<< " " <<;
    	};
    	cout <<endl;
    }
    
    
    
    
    int main(){
    
    
    
    
    	list<string> S;
    	
    
    	
    
    	S.push_back("a");
    	S.push_back("b");
    	S.push_back("c");
    	S.push_back("d");
    	S.push_back("e");
    	S.push_back("f");
    	S.push_back("g");
    	S.push_back("h");
        
    	S.push_front("x");
    	S.push_front("y");
    	S.push_front("z");
    
    	S.WriteList();
    
    	S.pop_back();
    	S.pop_back();
    	S.pop_back();
    
    	S.WriteList();
    
    	return 0;
    
    
    }
    Thanks!!

  2. #2
    Registered User dizolve's Avatar
    Join Date
    Dec 2002
    Posts
    68
    I've never used list before but I can see from MSDN that it has no function member named WriteList. Where'd you get your information?

    &nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;___&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;/\&nbsp;\&nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;/\_&nbsp;\&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;\_\&nbsp;\/\_\&nbsp;&nbsp;____&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_ __\//\&nbsp;\&nbsp;&nbsp;&nbsp;&nbsp;__&nbsp;&nbsp;__&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;
    &nbsp;/'_`&nbsp;\/\&nbsp;\/\_&nbsp;,`\&nbsp;&nbsp;/&nbsp;__`\\&nbsp;\&nbsp;\&nbsp;&nbsp;/\&nbsp;\/\&nbsp;\&nbsp;&nbsp;/'__`\&nbsp;
    /\&nbsp;\_\&nbsp;\&nbsp;\&nbsp;\/_/&nbsp;&nbsp;/_/\&nbsp;\_\&nbsp;\\_\&nbsp;\_\&nbsp;\&nbsp;\_/&nbsp;|/\&nbsp;&nbsp;__/&nbsp;
    \&nbsp;\___,_\&nbsp;\_\/\____\&nbsp;\____//\____\\&nbsp;\___/&nbsp;\&nbsp;\____\
    &nbsp;\/__,_&nbsp;/\/_/\/____/\/___/&nbsp;\/____/&nbsp;\/__/&nbsp;&nbsp;&nbsp;\/____/
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;I&nbsp;have&nbsp;a&nbsp;BAD&nbsp;figlet& nbsp;addiction.

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    You had a few mistakes.

    Code:
    #include<iostream>
    #include<string>
    #include<list>
    
    
    using namespace std;
    
    
    template<class T>
        void WriteList(list<T>& S)
    {
        list<T>::iterator iter;
    
        for(iter=S.begin();iter!=S.end();iter++)
    	    cout << *iter << " ";
        cout << endl;
    }
    
    
    
    
    int main()
    {
        list<string> S;
    
        S.push_back("a");
        S.push_back("b");
        S.push_back("c");
        S.push_back("d");
        S.push_back("e");
        S.push_back("f");
        S.push_back("g");
        S.push_back("h");
    
        S.push_front("x");
        S.push_front("y");
        S.push_front("z");
    
        WriteList( S );
    
        S.pop_back();
        S.pop_back();
        S.pop_back();
    
        WriteList( S );
    
        return 0;
    }

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    17
    Thanks for the help!! My professor gave me the code for WriteList.
    Thanks again!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21