OOPS in C++
#include <iostream> using namespace std; class student { private: int a,b,c; public: int d,e; void disdata() { cout<<"first num is "<<a<<endl; cout<<"second num is "<<b<<endl; cout<<"third num is "<<c<<endl; cout<<"fourth num is "<<d<<endl; cout<<"fifth num is "<<e<<endl; } void setdata(int a,int b,int c); }; void student:: setdata(int a1, int b1, int c1) { a=a1; b=b1; c=c1; } int main() { student peeyush; peeyush.setdata(5,6,7); peeyush.d=8; peeyush.e=9; peeyush.disdata(); return 0; }
Comments
Post a Comment