Archived

This topic is now archived and is closed to further replies.

Constructors that takes multiple arguments

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

if i have a class with a constructor taking two arguments, how do i set the values for it? With a constructor taking one argument, i can do it like this: class TestClass { public: TestClass(int value) { a = value} private: int a; }; TestClass Test[5] = {1,4,7,4,9} With this form of class, the same does not work, how do i send it values at initialization when the constructor takes multiple arguments? Like this one: class B { B(int W, int H) { Width = W; Height = H } private: int Width, Height; };

Share this post


Link to post
Share on other sites