Answer to Question #224826 in C++ for snr

Question #224826

Create a class Customer with properties – customerid (integer), name, age, phone. Add necessary

constructors to initialize the data members. Create an object of Customer and initialize the data using

parametrized constructor. Print the customer object data in the main class.


1
Expert's answer
2021-08-10T04:28:59-0400
#include <iostream>


using namespace std;


class Customer{
private:
        int customerid;
        string name;
        int age;
        string phone;
public:
        Customer(int customerid_, string name_, int age_, string phone_) {
                customerid = customerid_;
                name = name_;
                age = age_;
                phone = phone_;
        }
        void display(){
                cout << "Customer Id: " << customerid << '\n';
                cout << "Name: " << name << '\n';
                cout << "Age: " << age << '\n';
                cout << "Phone: " << phone << '\n';
        }


};


int main()
{
        Customer customer = Customer(25, "Azimjon", 19, "+992985570302");
        customer.display();
        return 1;
}

Output:

Customer Id: 25
Name: Azimjon
Age: 19
Phone: +992985570302

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS