We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# Correct and Final Solution of Assignment No.3 Of CS201 Due Date 14 Jan 2013 Solved by Waqas Rasheed

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

Views: 4197

### Replies to This Discussion

No. ap khud lilkhoo. theek likhoo compile na hoto mai zimmadaar hon

jo loog solution ko ghalaat bata rahe hien .. after deadline mai ccp file b de do ga.. phr chck kar lena.. solution theek tha ya nahi..ya ap sirf ap ke mistake the

yar end kese krna hai

yeh lo aur mooj maro

Attachments:

This is wrong solution...

Correct solution is this

check it geys.. just run it on devc++

Attachments:

Rao Usman

its a wrong solution becasuse of you did not dynamaclly allocate the memory..

my solution is 100% correct

using namespace std;

#include<iostream>

#include<conio.h>

class Vehicle{
private:string company;
string model;
double year;
double engineCapacity;
public:
void setCompany(string cmp)
{company = cmp;
}
string getCompany()
{
return company;
}
void setModel(string md)
{
model = md;
}
string getModel()
{
return model;
}
void setYear(double yr)
{
year = yr;
}
double getYear()
{
return year;
}
void setEngineCap(double eCap)
{
engineCapacity = eCap;
}
double getEngineCap()
{
return engineCapacity;
}

Vehicle *ptr;
int numVehicle;
void getInput()
{cout"Enter number of vehicle:";
cin>>numVehicle;
ptr = new Vehicle[numVehicle];
for(int i=0;i<numVehicle;i++)
{string Cmp;
cout"\n\nVehicle "i+1endl;
cout"Enter the name of Vehicle maker company :";
cin>>Cmp;
ptr[i].setCompany(Cmp);
string md;
cout"Enter Vehicle model :";
cin>>md;
ptr[i].setModel(md);
double rg;
cout"Enter year of registration:";
cin>>rg;
ptr[i].setYear(rg);
double egC;
cout"Enter engine of thr Vehicle:";
cin>>egC;
ptr[i].setEngineCap(egC);
}

}
void display()
{ for(int i=0;i<numVehicle;i++)
{
cout"\n\n\nVehicle"i+1endl;
cout"\nCompany :"ptr[i].getCompany()endl;
cout"\nModel: "ptr[i].getModel()endl;
cout"\nYear:"ptr[i].getYear()endl;
cout"\nEngine Capacity in CC:"ptr[i].getEngineCap()endl;
}
}

Vehicle()
{
company = "ABC";
model = "xyz";
year = 2009;
engineCapacity = 1000;
}
~Vehicle()
{ cout"\nObject deleted\n";
}
};
int main()
{
Vehicle obj;
obj.getInput();
obj.display();
delete[] obj.ptr;
getch();
}
//by Emran Haakim

## Latest Activity

Abu Abdur Rehman liked Abu Abdur Rehman's blog post SEO Services Company
1 hour ago
Sana Sunny ツ liked Abu Abdur Rehman's blog post SEO Services Company
2 hours ago
Sana Sunny ツ replied to ARhum's discussion Poetry...!!!
2 hours ago
Sana Sunny ツ liked ARhum's discussion Poetry...!!!
2 hours ago
Sana Sunny ツ liked ARhum's discussion ****...Suno...****
2 hours ago
2 hours ago
2 hours ago
Sana Sunny ツ liked Zeeee's discussion ✫" Anaa "✫
2 hours ago

1

2

3

## HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!