Sign in to follow this  

initialize arrays in classes

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this