102k views
0 votes
Define the missing member function. Use "this" to distinguish the local member from the parameter name.

#include
using namespace std;
class CablePlan{
public:
void SetNumDays(int numDays);
int GetNumDays() const;
private:
int numDays;
};
// FIXME: Define SetNumDays() member function, using "this" implicit parameter.
void CablePlan::SetNumDays(int numDays) {
/* Your solution goes here */
return;
}
int CablePlan::GetNumDays() const {
return numDays;
}
int main() {
CablePlan house1Plan;
house1Plan.SetNumDays(30);
cout << house1Plan.GetNumDays() << endl;
return 0;
}

User Talijanac
by
5.6k points

1 Answer

3 votes

Answer:

this.numDays = numDays;

Step-by-step explanation:

You just need one line of code. "this." to access the class member, and the "." is the member access operator.

User Nathan Brown
by
5.2k points