Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > using templates as class members.

Reply
Thread Tools

using templates as class members.

 
 
tehn yit chin
Guest
Posts: n/a
 
      12-18-2003
Hi all,

I am starting to learn c++ and have come across a problem that I was
not able to get a hang of.

I have a class defintion such as

class vect
{
public:
vect();
~vect();

private

vector<int> my_ints;
}

Upon compling this, my compiler complains vector is used as type, but
is not defined as a type.

I want to do the above because I want to access my_ints in more than
one method in the vect implementation.

I am probably doing something totally stupid. Any help is appreciated.

thanks,
tyc
 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      12-18-2003
tehn yit chin wrote:
> Hi all,
>
> I am starting to learn c++ and have come across a problem that I was
> not able to get a hang of.
>
> I have a class defintion such as


#include <vector> // Did you do this?

> class vect
> {
> public:
> vect();
> ~vect();
>
> private
>
> vector<int> my_ints;


std::vector<int> my_ints;

/* Vector is in a namespace called std.
* See also the documentation for the "using" keyword.
*/

> }
>
> Upon compling this, my compiler complains vector is used as type, but
> is not defined as a type.
>
> I want to do the above because I want to access my_ints in more than
> one method in the vect implementation.
>
> I am probably doing something totally stupid. Any help is appreciated.
>
> thanks,
> tyc


 
Reply With Quote
 
 
 
 
Thomas Wintschel
Guest
Posts: n/a
 
      12-18-2003
"tehn yit chin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi all,
>
> I am starting to learn c++ and have come across a problem that I was
> not able to get a hang of.
>
> I have a class defintion such as
>
> class vect
> {
> public:
> vect();
> ~vect();
>
> private
>
> vector<int> my_ints;
> }
>
> Upon compling this, my compiler complains vector is used as type, but
> is not defined as a type.
>
> I want to do the above because I want to access my_ints in more than
> one method in the vect implementation.
>
> I am probably doing something totally stupid. Any help is appreciated.
>
> thanks,
> tyc


May be a namespace issue. Try:

std::vector<int> my_ints;


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Class templates and friend function templates BigMan C++ 1 07-23-2005 09:24 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM
using templates in templates John Harrison C++ 8 07-31-2003 12:00 PM



Advertisments