Tuesday, March 17, 2015

Program That Uses The Class Where The Member Function Are Defined Outside The Class? (C++)


Aim: Write a program that uses the class where the member function are defined outside the class?
Ans.

#include<iostream.h>
#include<conio.h>
class car
{
private:char color[20],model[20];
float cost;
public:
void get();
void out();
};
void car::get()
{
cout<<"Enter color,model no & cost\n";
cin>>color>>model>>cost;
}
void car::out()
{
cout<<"\tColor="<<color<<"\n"<<"\tModel="<<model<<"\n"<<"\tCost="<<cost;
}
void main()
{
class car c;
clrscr();
c.get();
c.out();
getch();
}




No comments:

Post a Comment