Mailinglist Archive: opensuse-programming (8 mails)
| < Previous | Next > |
Re: [opensuse-programming] Question on C++ and STL
- From: Jerry Feldman <gaf@xxxxxxx>
- Date: Sun, 21 Jan 2007 22:27:01 -0500
- Message-id: <20070121222701.13d9923d@xxxxxxxxxxx>
On Sun, 21 Jan 2007 22:13:52 +0100
Volker <volker@xxxxxxxxxxxx> wrote:
> > Am Sonntag, 21. Januar 2007 17:57 schrieb Jerry Feldman:
> > > containertest.cc: In member function ‘void MyClass<T>::erase(size_t)’:
> > > containertest.cc:13: error: expected `;' before ‘it’
> > > Note: I've included both <list> and <iterator>.
> > >
> > You must define that method in the header-file. The compiler can't generate
> > code unless it knows the actual type...
>
> So did you try moving the method
> void MyClass<T>::erase(size_t n)
> {
> std::list<T>::iterator it;
> ...
> }
> into the *header*file where your class definition is
Yes. That's exactly where it was in the original. My example is simply
a single C++ file, with the erase function defined inline within the
class definition.
--
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Volker <volker@xxxxxxxxxxxx> wrote:
> > Am Sonntag, 21. Januar 2007 17:57 schrieb Jerry Feldman:
> > > containertest.cc: In member function ‘void MyClass<T>::erase(size_t)’:
> > > containertest.cc:13: error: expected `;' before ‘it’
> > > Note: I've included both <list> and <iterator>.
> > >
> > You must define that method in the header-file. The compiler can't generate
> > code unless it knows the actual type...
>
> So did you try moving the method
> void MyClass<T>::erase(size_t n)
> {
> std::list<T>::iterator it;
> ...
> }
> into the *header*file where your class definition is
Yes. That's exactly where it was in the original. My example is simply
a single C++ file, with the erase function defined inline within the
class definition.
--
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
| < Previous | Next > |