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.
#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
Comments
Leave a comment