• Advertisement
Sign in to follow this  

Vectors in classes

This topic is 2775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can i have a vector in a class ?


#include<vector>

class _test
{
public:

private:
std::vector<char> nav(5); // expected `;' before '(' token
};

int main()
{
}


Share this post


Link to post
Share on other sites
Advertisement
Use constructor & initializer list to set size of vector:


class _test
{
private:
std::vector<char> nav; // expected `;' before '(' token
public:
_test() : nav(5) {};
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement