Jump to content
  • Advertisement
Sign in to follow this  
slowburn15

Vectors in classes

This topic is 2891 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!