Hi there, is it possible to intialize a private container members
Such as a vector in a class.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class intial
{
Public:
/// some stuff here
Private:
Vector< otherclass > member(5);// is this possible
};
Or
class temp
{
Public:
/// stuff here
Private:
Static Constexpr size_t foo=4;
Vector <otherclass> myvec (foo);
/// is this possible.
};
well @miniippa your way works, I have tested by providing a contructor
member(5)
And am wondering too, what if I wanted to provide arguments to each of
The five objects constructor at the same time is it possible? How can that be done
If possible?
Haha im now on track @minnippa you seem to be having all I need, Thank you so much
All your ways are working just fine , it is great n am putting it to practice, ill get back if a thing fails
Good job.
1) line 7 Int data; should be: int data;
2) std::vector <other> myvec (foo); is not doing what do you want here!
It declares a member function which takes and object of (nonexistent) type foo. You need to use uniform initialization to give default value for that member: std::vector <other> myvec {foo}; .
Note the curly braces {} instead of usual ()
Wow wow ! Exactly, how the hell didn't I see that? Yeah I errorneously made a function instead of
Vector variable , thank you so much @minnippa uniform intialization seems to be a thing am missing , av tested std::vector <other> myvec {foo}; it n it's working now
This av been a big time question now it is fully solved, Thenk you for your time, that was great , can't believe it.