Pressing_Keys_24_7
Pressing_Keys_24_7

Reputation: 1863

Accessing Private Members of a class outside the class

I have defined two classes as follows:-

class DayStat
{
private:
    double cases, deaths;
public:
    DayStat();
    DayStat(int _cases, int _deaths);
    DayStat(const DayStat &d, double denominator);
    double mortalityRate() const;
    double getcases() const;
    double getdeaths() const;
};

class Region
{
private:
    DayStat *raw;
    char *name;
    int population;
    int area;
    int nday;
};

Now, I want to store the cases and deaths of the DayStat class which are private into the raw dynamic array being defined in the Region class. That is raw should store the cases and deaths of a region. But, I am not sure how to access the 2 private members (cases and deaths) from the DayStat class in the Region class. Any help would be appreciated! Thanks!

Upvotes: 1

Views: 87

Answers (1)

john
john

Reputation: 88092

Like this

raw[10] = DayStat(20, 30);

Upvotes: 2

Related Questions