Class is very important term in Object Oriented Programming .Class is abstract data type which mean it defined by user . In this problem a class with the name LEP and it contain two variables. In main function we just make a object.
Source Code
#include<iostream> using namespace std; class LEP { int num1,num2; public: void set_values(int ,int ); int add() { return (num1+num2); } }; void LEP::set_values(int a,int b) { num1=a; num2=b; } int main () { LEP L; int a,b; cout<<" Enter Your Number Here .....! : \n "; cin>>a; cout<<" Enter Your Number Here .....! : \n "; cin>>b; L.set_values(a,b); cout<<" This is the Sum of Two Numbers :" << L.add(); }
0 comments:
Post a Comment