#default constructor and vector

15 messages · Page 1 of 1 (latest)

thick pebble
#

How can i initialize a null vector in a default constructor?

honest islandBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

brittle wyvern
#

wdym

thick pebble
#

like lets say the private variables in a class are type int

#

in the default constructor, youd do int ... = 0;

#

what do you do if youre private variable is a vector

strange jewel
#

as an empty vector

thick pebble
#

yes but how do you declare the empty vector

#

just vector <int> ...; ?

strange jewel
#

when you don't initialize fields which are classes, like the vector, the default constructor gets used automatically to initialize those fields

thick pebble
#

okay so i dont have to make it equal to anything

thick pebble
#

bet thanks

honest islandBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.