constructor assign question

two constructors, one is default and another one is parameter taking. I am wondering what value should I assign to the bold part. should those be "M", "F", "0", "0", "undefined" or current is correct?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//constructor
DateProfile::DateProfile(){
   gender = 'M';
   searchGender = 'F';
   romance = 0;
   finance = 0;
   name = "undefined";
}

DateProfile::DateProfile(char gender, char searchGender,
            int romance, int finance, string name) {
   this->gender = gender;
   this->searchGender = searchGender;
   this->romance = romance;
   this->finance = finance;
   this->name = name;
}
Last edited on
1. I think you're right. But indeed this may depend on your ideas of what gender, searchGender, ... should contain.

2. It may be useful to validate your actual parameters. F.e. you may want your gender attribute to contain only one of the value 'M', 'F' or 'U'. Then you should check this before the assignment.
Topic archived. No new replies allowed.