Write a program to demonstrate the out side class definition

//this is a program to demonstrate the out side class definition
#include<iostream>
#include<conio.h>

using namespace std;

class Sample
{
int x,y;

public:

//Member Function
void accept();
void display();
};

//Outside Defination

void Sample::accept()
{
cout<<"\n\nEnter any two numbers: ";
cin>>x>>y;
}

void Sample::display()
{
cout<<"\n\nX: "<<x;
cout<<"\n\nY: "<<y;
}

int main()
{
//Object declaration
Sample s;

//Function Call
s.accept();
s.display();

return 0;
}

Previous
Next Post »