Respuesta :
Answer:
#include
using namespace std;
class PhonePlan{
public:
PhonePlan();
PhonePlan(int numMinutes, int numMessages);
void Print() const;
private:
int freeMinutes;
int freeMessages;
};
PhonePlan::PhonePlan() { // Default constructor
freeMinutes = 0;
freeMessages = 0;
return;
}
PhonePlan::PhonePlan(int numMinutes, int numMessages) {
freeMinutes = numMinutes;
freeMessages = numMessages;
return;
}
void PhonePlan::Print() const {
cout << "Minutes: " << freeMinutes << ", Messages: " << freeMessages << endl;
return;
}
int main() {
PhonePlan user1Plan;
PhonePlan user2Plan(1000, 5000);
cout << "User1: ";
user1Plan.Print();
cout << "User2: ";
user2Plan.Print();
return 0;
}
Explanation:
The C++ source code has a defined class called "PhonePlan" with a default constructor which initializes the phone time and messages of a user to zero and another constructor method which assigns the "numMessages" and "numMinutes" to the user messages and minutes and displays it in the console.