• Advertisement
Sign in to follow this  

initialize arrays in classes

This topic is 4159 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

Hi all gurus out there. I have a question about haw to initialize arrays in classes. I did not find any old treads with this question. Ex, what I want! Class x { public: x() : m_arrayX({1,2,3,4}), m_arrayY({5,6,7,8}) {} private: int m_arrayX[]; int m_arrayY[4] }; hope you se what I want. A other idée is to make it to pointer and use m_arrayX[] = new int[] = {1,2,3,4}; But I what to try to not use the “new” commando. As it is now in my code. .H int m_arrayX[]; .CPP m_arrayX[0] = 1; m_arrayX[1] = 0; m_arrayX[2] = 0; m_arrayX[3] = 4; thanks all out there!

Share this post


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

  • Advertisement