Struct into classes

Im trying to define a object type called HealthProfile class for a person. A HealthProfile object and it has the following members a struct containing a person’s first name, last name, gender, date of birth (another struct, with attributes month, day and year), height (in inches) and weight (in pounds).
Here's what I got so far....can i get feedback on whether im on the right path. Thanks

class HealthProfile
{
Private:
struct PatientInfo
{
string fname;
string lname;
char gender;
};

struct DateofBirth
{
int day
int month;
int year;
};

struct HeightWeight
{
int height;
int weight;
};
whats with the random brace?
1
2
3
4
5
6
7
8
9
10
class HealthProfile
{
Private:
struct PatientInfo
//{
string fname;
string lname;
char gender;
};
Last edited on
whats with the random brace?

That's not a random brace, it's the start of a struct definition. The OP is defining some struct types within the HealthProfile class.

To the OP:

That seems fine so far, except that the access specifier private: is all lower-case, and you haven't put a closing brace and semicolon on your class definition.

Are you certain that you want the type definitions of PatientInfo, DateofBirth and HeightWeight to be private? This means that only the methods of HealthProfile will be able to use those types.

Edit: Note that all you've done so far is defined some types. You haven't actually declared any data members of those types, e.g.

1
2
3
4
  PatientInfo m_patientInfo;
  DateofBirth m_patientDOB;
  HeightWeight m_patientHeightWeight;
  
Last edited on
Topic archived. No new replies allowed.