[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird list.begin() error

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) 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 is
nornally called is an 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> >*'

#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();


   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{
    PlayList(){l.push_back("String 1");       l.push_back("String
2");l.push_back("String 3");}

    list<string>* getList() {return &l;}
        list<string> l;


  Karthik.      .
  ' Remove _nospamplz from my email to mail me. '

reply via email to

[Prev in Thread] Current Thread [Next in Thread]