Send to a Friend

HeroicZach's avatar

Is it possible in C++ to declare a vector of characters as a private variable in a class header file? If so, why isn't it working for me?

Asked by HeroicZach (195points) September 19th, 2009

When I declare, like this:

class myClass
{
public:
//public functions
private:
vector<char> myVector;
}

The program compiles, but when I set up the default constuctor in the .cpp file that matches up with this .h class header, like this:

myClass::myClass()
{
myVector(‘a’,‘b’,‘c’);
}

…the program does not compile. What’s the deal?

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.