Define a class License that has a driving license number, name and address. Define
constructors that take on parameter that is just the number and another where all
parameters are present.
#include <iostream>
using namespace std;
class License {
int number;
string name;
string address;
public:
License(int num) {
number = num;
name = "N/A";
address = "N/A";
}
License(int num, string nm, string adr) {
number = num;
name = nm;
address = adr;
}
void print() {
cout << "License number: " << number << endl;
cout << "Name: " << name << endl;
cout << "Address: " << address << endl;
}
};
int main() {
License l1(1234567);
License l2(987655, "Jhon Dow", "48 Oak str, Sommerville");
l1.print();
cout << endl;
l2.print();
}
Comments
Indeed, you are more than experts, thanks alot I really appreciate
Leave a comment