Simple Parameter Constructor
Simple Parameter Constructor
Just open your c++ compiler Paste this code.
#include<iostream>
using namespace std;
class emp
{
private :
int em,co;
public :
emp() :em(0) , co(0)
{
}
emp(int empo ,int comp) : em(empo) , co(comp)
{
}
int setemployee(int bc,int ac)
{
cout<<"Employee No IS : "<<bc<<endl;
cout<<"Employee salary is : "<<ac<<endl;
}
};
int main()
{
emp p;
int a,b;
cout<<"Enter Employee NO : ";
cin>>a;
cout<<"Enter Employee Salery : ";
cin>>b;
emp as(a,b);
p.setemployee(a,b);
emp as1(a,b);
p.setemployee(a,b);
}
Just open your c++ compiler Paste this code.
#include<iostream>
using namespace std;
class emp
{
private :
int em,co;
public :
emp() :em(0) , co(0)
{
}
emp(int empo ,int comp) : em(empo) , co(comp)
{
}
int setemployee(int bc,int ac)
{
cout<<"Employee No IS : "<<bc<<endl;
cout<<"Employee salary is : "<<ac<<endl;
}
};
int main()
{
emp p;
int a,b;
cout<<"Enter Employee NO : ";
cin>>a;
cout<<"Enter Employee Salery : ";
cin>>b;
emp as(a,b);
p.setemployee(a,b);
emp as1(a,b);
p.setemployee(a,b);
}








0 comments: