hello ppl i am a new member of the programming club it been a week since i begin to program and i am doing it persnaly so i am sorry if what i posted is stupid but i want u u guys to have a look and tell me whats wrong with this code the question is as under
Q Write a definition of class named Phone that has three private elements country code, the
city code and the number.
• Write two constructors, a default constructor (that initialize each data element of
object with zero) and a constructor that takes three parameters (country code, city
code and the number) and initialize the data member of the object with these
parameters.
• Write a function void printPhone() that displays the data elements of the object.
• Write a function void setPhone(int, int, int) that takes three parameters (country
code, city code and the number) and initialize the data member of the object with
these parameters.
Write a main function create two object of class Phone, the data member of one object is
initialized with zero through default constructor. The data member of second object is
initialized with some values using a constructor that takes three parameters.
Prompt the user to input values (country code, city code and a number) in a main
function, assign these values to the first object (using function setPhone) and display the
value of the data members of two objects using function printPhone().
ans====
#include<iostream.h>
#include<conio.h>
class phone
{
int country,city,no;
public:
phone():country(0),city(0),no(0)
{}
phone(int a,int b,int c):country(a),city(b),no(c)
{
void setphone(a,b,c)
{ cout<<"enter the codes count city no";
cin>>a>>b>>c;
} };
main()
{
phone p1,p2(a,b,c);
p1.setphone(intx,inty,intz);
p1.printphone();
p2.printphone() ;
}