473,769 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Vehicle program

5 New Member
I'm going to have to break this up into files however I receiving errors when I try to compile this. I am confused about this program Please help.I.m using Visual C++ platform, XP operating system

enclosed are the errors I'm getting and the code



Vehicle.cpp
Vehicle.cpp(35) : error C2511: 'Person::Person (Person &)' : overloaded member fu
nction not found in 'Person'
Vehicle.cpp(10) : see declaration of 'Person'
Vehicle.cpp(40) : error C2511: 'std::string Person::getName (void)' : overloaded
member function not found in 'Person'
Vehicle.cpp(10) : see declaration of 'Person'
Vehicle.cpp(45) : error C2511: 'Person &Person::operat or =(Person &)' : overload
ed member function not found in 'Person'
Vehicle.cpp(10) : see declaration of 'Person'
c:\Documents and Settings\Warren Hoskins\My Documents\C++ programs in progress\P
erson.h(7) : error C2011: 'Person' : 'class' type redefinition
Vehicle.cpp(10) : see declaration of 'Person'
Vehicle.cpp(91) : error C2065: 'Manufacturer' : undeclared identifier
Vehicle.cpp(92) : error C2065: 'OwnerName' : undeclared identifier
Vehicle.cpp(93) : error C2065: 'Numofcyl' : undeclared identifier
Vehicle.cpp(96) : error C2061: syntax error : identifier 'Numofcyl'
Vehicle.cpp(97) : error C2511: 'Vehicle::Vehic le(std::string) ' : overloaded memb
er function not found in 'Vehicle'
Vehicle.cpp(73) : see declaration of 'Vehicle'
Vehicle.cpp(105 ) : error C3861: 'Manufacturer': identifier not found, even with
argument-dependent lookup
Vehicle.cpp(108 ) : error C2039: 'getOwnerName' : is not a member of 'Vehicle'
Vehicle.cpp(73) : see declaration of 'Vehicle'
Vehicle.cpp(110 ) : error C3861: 'OwnerName': identifier not found, even with arg
ument-dependent lookup
Vehicle.cpp(113 ) : error C2039: 'getNumofcyl' : is not a member of 'Vehicle'
Vehicle.cpp(73) : see declaration of 'Vehicle'
Vehicle.cpp(116 ) : error C3861: 'Numofcyl': identifier not found, even with argu
ment-dependent lookup

C:\Documents and Settings\Warren Hoskins\My Documents\C++ programs in progress> I'm programming in C++

#include <iostream>
#include<cstdli b>
#include<string >
using namespace std;




class Person
{
public:
Person ();
Person (string theName);
Person (const Person& theObject);// this is confusing me
string getName()const;
Person& operator=(const Person& rtSide);// and this rtSide; I don't understsnd
friend istream& operator >>(istream& inStream,Person & personObject);
friend ostream& operator <<(ostream& outstream,const Person& personObject);

protected:
string name;
};


Person::Person( ) : name("Unknown")
{
}

Person::Person( string theName)
{
name = theName;
}

Person::Person( Person& theObject)
{
name = theObject.getNa me();
}

string Person::getName ()
{
return name;
}

Person& Person::operato r =(Person& rtSide)
{
name = rtSide.getName( );
return *this;
}

istream& operator >>(istream& inStream, Person& personObject)
{
inStream >> personObject.na me;
return inStream;
}

ostream& operator <<(ostream& outStream, const Person& personObject )
{
outStream << personObject.na me;
return outStream;
}




//#ifndef VEHICLE_H
//#define VEHICLE_H
#include <iostream>
#include <string>
#include "person.h"
using namespace std;

class Vehicle
{
public:
Vehicle();
Vehicle(string, int, Person);
string getManufacturer (){return manufacturer;}
int getCylinders(){ return cylinders;}
string getOwner(){retu rn vehicleOwner.ge tName();}

protected:
string manufacturer;
int cylinders;
Person vehicleOwner;

};

//#endif
Vehicle::Vehicl e() // default constructor
{
Manufacturer = "No name";
OwnerName = "None";
Numofcyl = 0;
}

Vehicle::Vehicl e( string theManufacturer ,Numofcyl, Person theOwnerName)
{
Manufacturer = theName;
OwerName = theOwnerName;
Numofcyl = 0;
}

string Vehicle::getMan ufacturer() // accessor function to getManuf Name
{
return Manufacturer;
}

string Vehicle::getOwn erName() // accessor function toOwnerName
{
return OwnerName;
}

int Vehicle ::getNumofcyl() // accessor function to getNumofcyl

{
return Numofcyl;
}

//#ifndef truck_h
//#define truck_h
#include <iostream>
#include "person.h"
#include "vehicle.h"
using namespace std;


class Truck : public Vehicle
{
public:
Truck();
Truck(string, int, Person, double, int);
Truck(Truck& rtSide);// the right side of what
double getLoadCapacity (){return loadCapacity;}
int getTowingCapaci ty(){return towingCapacity; }
Truck& operator=(Truck & rtSide); // need help here

protected:
double loadCapacity;
int towingCapacity;
};

Truck::Truck(): Vehicle() // inherited from the base class
{
loadCapcity = 0;
towingcapacity = 0;
}

Truck::Truck(): getLoadCapacity (loadCapacity) // inheriting from the vehicle class
{

return loadCapacity;
}

Truck::Truck(): getTowingCapaci ty(towingCapaci ty)
{
return towingCapacity;
}



int main()
{

//testing implemented person class
Person owner("John Williams");
Person owner2;

//testing constructors
Truck truckObject1;
//manufacturer, no of cylinders, owner, load capacity(tons), towing capacity(pounds )
Truck truckObject2("F ord",8,owner,1. 5,1500);

//testing assignment operator
truckObject1 = truckObject2;

//first 3 methods are inherited from vehicle class (getManufacture r,getCylinders, getOwner )
cout <<"Manufacturer : " <<truckObject1. getManufacturer () <<endl;
cout <<"Cylinders: " <<truckObject1. getCylinders() <<endl;
cout <<"Owner: " <<truckObject1. getOwner() <<endl; // should return a string
cout <<"Load Capacity: " <<truckObject1. getLoadCapacity () <<endl;
cout <<"Towing Capacity: " <<truckObject1. getTowingCapaci ty() <<endl<<endl;


//testing overload stream extraction and insertion operators
cout<<"Enter a new owner name: ";
cin >> owner2;

cout<<"Verify owner: " <<owner2<<end l;

Truck truckObject3("D odge",8,owner2, 1,1200);

//testing copy constructor
Truck truckObject4(tr uckObject3);

cout <<"Manufacturer : " <<truckObject4. getManufacturer () <<endl;
cout <<"Cylinders: " <<truckObject4. getCylinders() <<endl;
cout <<"Owner: " <<truckObject4. getOwner() <<endl;
cout <<"Load Capacity: " <<truckObject4. getLoadCapacity () <<endl;
cout <<"Towing Capacity: " <<truckObject4. getTowingCapaci ty() <<endl;

system("pause") ;
return 0;
{
Apr 6 '07 #1
2 3814
Ganon11
3,652 Recognized Expert Specialist
Please don't double post your question - the second thread has been deleted.
Apr 7 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
Let's fix one error:

Vehicle.cpp(35) : error C2511: 'Person::Person (Person &)' : overloaded member fu
nction not found in 'Person'

look in your Person class:

Person (const Person& theObject);// this is confusing me

and you implementation:

Person::Person( Person& theObject)
{
name = theObject.getNa me();
}


See any difference??
Apr 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
6342
by: noname | last post by:
Hello all, I use Access to keep track of approx. 80 vehicles. I have a table of vehicles with specs. I have another of service records linked to the vehicle table. Works great! I can expand each vehicle to see what service I have performed on just that vehicle. I also have tables for billing categories, employees and departments. So far so good. Now I need to make it to where I can enter the fuel used by each vehicle when someone fills...
1
4827
by: Johann Blake | last post by:
You can read an article on a novel approach on how to build an inexpensive system to track a vehicle or any other type of object using a GPS receiver and other off-the-shelf hardware like a GSM/GPRS modem. The article is found at: http://www.closerworlds.com/eng/Resources/GPS_Vehicle_Tracking.html This is part I in a series. By CloserWorlds
6
5297
by: jimfortune | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/60d7faa790c65db1 james.ea...@gmail.com said: :Ok, I've answered the first half of my own question. From a MSDN :article, I can now use the following to reference the last primary :key's values: :
35
1933
by: javelin | last post by:
I posted an answer to someone's question, and realized I have more questions than answers. Thus, I am going to post my scenario to get to the question that I have: I have a challenge, to figure out what part of the vehicle to relate parts to. I can't relate a part to the entire vehicle. Why? Well, a vehicle can have, apparently, more than one engine configuration. For example, I have a Honda Civic with a 1.5L engine, and it can come with...
1
1705
by: cm04jahn | last post by:
hi all, been working on a project all week and pretty much going nowhere fast. i've never used java before and my professor isn't very helpful. For my first project we are creating a ticket which prompts the type of vehicle (car truck senior), and the number of minutes it has been parked for. Then the ticket should print output of the type of vehicle, the time in hours it has been in the parking lot, and the total cost for the parking...
6
3514
by: xdeath | last post by:
Hi guys, at the moment, im rushing to get my assignment done as the dateline is soon. Haven't had much time lately, so i'm in need of some help. Im supposed to create a program that : Has a Vehicle superclass, and a Taxi subclass. 1) Can accept new Taxi into an array 2) Can delete old records of Taxi from the array 3) Have to be able to retain the previous added data (which i think most likely im gonna do it by saving and reading the...
2
1153
by: MLH | last post by:
Suppose you have tblVehicleJobs with keyfield. And say there's another table used to keep records of inbound letters you receive on each car. That table is named tblinLttrs and has as it's keyfield and has field which is used to link it to tblVehicleJobs. Since many letters (of several categories) could be sent in over time pertaining to a given vehicle, there is a hard-coded One To Many relationship from tblVehicleJobs to tblinLttrs...
0
1266
by: vince | last post by:
Until December, 31st, 2008 companies may obtain a free Developer License of the JOpt.NET Vehicle Routing Library The Vehicle Routing Initiative aims on software vendors that plan to incorporate advanced route planning and optimization features into their existing software product. Be it in Logistics, Field Service or Sales Force Planning ISVs are encouraged to contact DNA at http://www.dna-evolutions.com/vrinitiative.html
0
1180
by: vince | last post by:
Until December, 31st, 2008 companies may obtain a free Developer License of the JOpt.SDK Vehicle Routing Library The Vehicle Routing Initiative aims on software vendors that plan to incorporate advanced route planning and optimization features into their existing software product. Be it in Logistics, Field Service or Sales Force Planning ISVs are encouraged to contact DNA here to obtain a free Developer Express License including email...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.