Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Wednesday, September 7, 2016

PROGRAM TO ILLUSTRATE THE CONCEPT OF INLINE FUNCTION WITHIN THE CLASS

PROGRAM TO ILLUSTRATE THE CONCEPT OF INLINE FUNCTION WITHIN THE CLASS.

#include <iostream>
using namespace std;
class square
{
public:
int num;

void getdata()
{
cout<<"Enter the Number: ";
cin>>num;
}

int sq();
};

inline int square::sq()
{
return (num*num);
}

int main()
{
square s;
s.getdata();
cout<<"\nSquare of Number is "<<s.sq();
}



Friday, September 2, 2016

PROGRAM TO ILLUSTRATE THE CONCEPT OF CLASS AND OBJECT:
// program to illustrate the concept of classes ans=d objects
#include<iostream>
using namespace std;
class student
{
private:
int rollno;
float marks;
char name[20];
public:
void getdata()
{
cout<<"ENTER NAME ";
cin>>name;
cout<<"ENTER ROLL NO";
cin>>rollno;
cout<<"ENTER MARKS";
cin>>marks;
}
void print()
{
cout<<"YOU ENTERED";
cout<<"\nNAME: "<<name;
cout<<"\nROLL NO: "<<rollno;
cout<<"\nMARKS: "<<marks;
}
};
main()
{
student s;
s.getdata();
s.print();
}