Jan 16, 2016 at 1:59pm UTC
if i have a constructor like Attraction(int id,string name,int typeID):id(id),name(name),typeID(typeID){} //this is with the member list initialization
do i still need Set function for each of the attributes?
Last edited on Jan 16, 2016 at 2:01pm UTC
Jan 16, 2016 at 2:20pm UTC
That's up to you. Do you want to be able to set the values of those attributes after construction, or not?
Jan 17, 2016 at 4:47am UTC
but using constructor also can set values ?
Jan 17, 2016 at 8:33am UTC
But if you want to modify only typeID. You got to have a set function for typeID.
Jan 18, 2016 at 11:19am UTC
if got constructor with member initialization ,why we still need a set values for the class?
Jan 18, 2016 at 11:21am UTC
if got constructor with member initialization ,why we still need a set values for the class?
To perhaps set the value whenever you want? Values change you know.
Last edited on Jan 18, 2016 at 11:30am UTC
Jan 18, 2016 at 2:18pm UTC
Set is for changing the values of attributes when needed
Jan 18, 2016 at 2:26pm UTC
Right. So hopefully you can see the difference between that and a constructor?
Jan 18, 2016 at 3:43pm UTC
yes,is it my ram problem? i loaded very long sometimes,i using windows 10
Jan 18, 2016 at 3:47pm UTC
mike9407 wrote:yes,is it my ram problem? i loaded very long sometimes,i using windows 10
Um... what? What does that have to do with constructors and setters?
Last edited on Jan 18, 2016 at 3:47pm UTC
Jan 19, 2016 at 6:23am UTC
Refer to my another topic ,not this topic
Jan 19, 2016 at 9:42am UTC
It's better if you stick to the right topic in the right thread. Otherwise, you just confuse people.
Jan 19, 2016 at 11:39am UTC
@MikeyBoy Maybe that has been his plan all along, considering the title.