struct one

{
int a1;
void display()
{
          cout << “Struct method”;
}

};

class cone

{
int a2;

void display()
{
           cout << “Class method”;
}

};

int main()

{
          one a;
a.display();

cone b;
b.display();
return 1;

}

OUTPUT :-

In function ‘int main()’:
Line 19: error: ‘void cone::display()’ is private
compilation terminated due to -Wfatal-errors.

************************************************************

struct one

{
int a1;
void display()
{
cout << “Struct methodn”;
}

};

class cone

{
int a2;

public:

void display()
{
cout << “Class methodn”;

}

};

int main()

{
one a;
a.display();

cone b;
b.display();
return 1;

}

OUTPUT :-

Struct method
Class method