C++. This-> pointer simple program
#include <iostream>
using namespace std;
class emp
{
public:
int id;
string name;
int sal;
emp(int id,string name,int sal)
{
this-> id=id;
this-> name=name;
this-> sal=sal;
}
void display()
{
cout<<id<<" "<<name<<" "<<sal<<" ";
}};
int main()
{
emp e1=emp(21,"yash",35000);
e1.display();
return 0;
}
Comments
Post a Comment