[Top][All Lists]

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

weird list.begin() error

From: tlann
Subject: weird list.begin() error
Date: Thu, 4 Nov 2004 17:18:09 -0700

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

        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;


reply via email to

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