473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Vehicle program

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::operator =(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::Vehicle(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<cstdlib>
#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.getName();
}

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

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

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

ostream& operator <<(ostream& outStream, const Person& personObject )
{
outStream << personObject.name;
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(){return vehicleOwner.getName();}

protected:
string manufacturer;
int cylinders;
Person vehicleOwner;

};

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

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

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

string Vehicle::getOwnerName() // 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 getTowingCapacity(){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():getTowingCapacity(towingCapacity)
{
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("Ford",8,owner,1.5,1500);

//testing assignment operator
truckObject1 = truckObject2;

//first 3 methods are inherited from vehicle class (getManufacturer,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.getTowingCapacity() <<endl<<endl;


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

cout<<"Verify owner: " <<owner2<<endl;

Truck truckObject3("Dodge",8,owner2,1,1200);

//testing copy constructor
Truck truckObject4(truckObject3);

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.getTowingCapacity() <<endl;

system("pause");
return 0;
{
Apr 6 '07 #1
2 3783
Ganon11
3,652 Expert 2GB
Please don't double post your question - the second thread has been deleted.
Apr 7 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
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.getName();
}


See any difference??
Apr 7 '07 #3

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

Similar topics

2
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...
1
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...
6
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...
35
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...
1
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...
6
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...
2
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...
0
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.