|
From: | Karthik Kumar |
Subject: | Re: weird list.begin() error |
Date: | Thu, 04 Nov 2004 16:32:13 -0800 |
User-agent: | Mozilla Thunderbird 0.8 (Windows/20040913) |
tlann@technoeclectic.com wrote:
I don't quite understand why this doesn't work. I tried on another os and compiler and it worked. It might be because the other compiler isn't as ANSI compliant but I'm not sure. Can someone tell me why begin() from a list outside of where the list isnornally called is an error?Error ++++++++++++ /home/tharper/Code/listtest/src/main.cpp:38: error: request for member ` begin' in `p', which is of non-aggregate type `std::list<std::string, std::allocator<std::string> >*' =====================main.cpp #include <iostream> #include <cstdlib> #include <string> #include <list> #include "playlist.h" using namespace std; int main(int argc, char *argv[]) { PlayList pL; list<string> *p=pL.getList();list<string>::iterator liter=p.begin();
p->begin(); How could this have worked with any other compiler ? I fail to understand .
return EXIT_SUCCESS; } ============== #ifndef PLAYLIST_H #define PLAYLIST_H #include <string> #include <list> using namespace std; /** @author tharper */ class PlayList{ public: PlayList(){l.push_back("String 1"); l.push_back("String 2");l.push_back("String 3");} ~PlayList(){;} list<string>* getList() {return &l;} protected: list<string> l; }; #endif
-- Karthik. http://akktech.blogspot.com . ' Remove _nospamplz from my email to mail me. '
[Prev in Thread] | Current Thread | [Next in Thread] |