Answer to Question #285119 in C++ for Hassan Madu

Question #285119

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.




1
Expert's answer
2022-01-06T02:01:30-0500
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Hassan Madu
06.01.22, 18:43

Indeed, you are more than experts, thanks alot I really appreciate

Leave a comment

LATEST TUTORIALS
New on Blog