By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,301 Members | 1,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,301 IT Pros & Developers. It's quick & easy.

using templates as class members.

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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


Jul 22 '05 #2

P: n/a
"tehn yit chin" <te*********@hotmail.com> wrote in message
news:19**************************@posting.google.c 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;
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.