Alisha Naaz http://vualisha.blogspot.com E-mail: vualisha@gmail.com

......Indian Songs.......

>

Wednesday, January 27, 2010

CS 201 ass # 5

#include
using namespace std;

class Train
{
public:
float getMaxSpeed();
void setMaxSpeed(float);
Train(); //default constructor
Train(float); //overloaded constructor
private:
float maxSpeed;
};


Train::Train()
{
maxSpeed = 250;
cout<<"\nDefault Constructor : Maximum Speed = \t\t" <}


Train::Train(float maximumSpeed)
{
maxSpeed = maximumSpeed;
cout<<"\nOverloaded Constructor : Maximum Speed = \t\t" <}


float Train::getMaxSpeed()
{
return maxSpeed;
}


void Train::setMaxSpeed(float ms)
{
maxSpeed = ms;
}


int main()
{
// displaying value through overloaded constructor
Train train1(100);

Train *train2 = new Train(); //dynamically allocating memory to train2
float maximumSpeed;

cout<<"\n\nEnter the maximum speed of Train: \t\t";
cin>>maximumSpeed;
train2->setMaxSpeed(maximumSpeed);

cout<<"Updated Speed : \t\t"<getMaxSpeed()<<"\n\n";


delete train2; //releasing the memory allocated to train2

system("pause");
return 0;
}

0 comments:

Searching Video

Vu Alisha Search

VUalisha Followers (Jion Now and Get Extra benefits)

Contact Us

My photo
E-mail: vualisha@gmail.com