Errors While writing Car Class program please help!!

Hi everyone,
Ive been writing this code all day and these errors have been killing. Please if you can help me I can't seem to fix it. Your help is greatly appreciated!

Thank You!

Instructions:
Car Class:
Write a class named Car that has the following:
year. An int that holds the cars model year.
make. A string object that holds the make of car.
speed. An int that holds the cars current speed.

In addition, the class should have the following member functions.

Constructor. The constructor should accept the car's year and make as arguments and assign these values to a object's year and make member variables. The constructor should initialize the speed member variable to 0.

Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's year, make, and speed member variables.

accelerate. the accelerate function should add 5 to the speed member variable each time it is called.

brake. The brake function should subtract 5 from the speed member variable each time it is called.

Demonstrate the class in a program that creates a Car object, and then calls accelerate function five times. After each call to the accelerate function, get the current speed of the car and display it. The, call the brake function five times. After each call to the brake function, get the current speed of the car and display it.

Errors: error C2061: syntax error : identifier 'stringm'
error C2533: 'Car::{ctor}' : constructors not allowed a return type
error C2511: 'Car::Car(int)' : overloaded member function not found in 'Car'
see declaration of 'Car'
fatal error C1903: unable to recover from previous error(s); stopping compilation



#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;




class Car

{

private:

int yearModel;
string make;
int speed;



public:

Car(int, string, int);
void accelerate();
void brake();
void setYear(int y);
int getYear();
void setSpeed(int s);
int getSpeed();
void setMake(string m);
string getMake();

}




Car::Car(int y, stringm,)

{
yearModel=y;

make=m;

speed=0;
}


void Car::setYear(int y)

{
yearModel=y;
}


int Car::getYear()

{
return yearModel;
}




void Car::setMake(string m)

{
make = m;
}



string Car::getMake()

{
return make;
}


void Car::setSpeed(int s)

{
speed = s;
}



int Car::getSpeed()

{
return speed;
}


void Car::accelerate()

{
speed = speed + 5;
}




void Car::brake()

{
speed = speed - 5;
}




int main()

{

Car Scion(2013, "FRS");

cout<<"Accelerate"<<endl;

for(int i = 0; i < 5; i++)

{

Scion.accelerate();

cout<<"Current Speed: "<<Scion.getSpeed()<<endl;

}

cout<<endl;

cout<<"Decelerate"<<endl;

for(int i = 0; i < 5; i++)

{

Scion.brake();

cout<<"Current Speed: "<<Scion.getSpeed()<<endl;

}




return 0;

}




/*int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
*/



Please use code tags when posting
http://www.cplusplus.com/articles/z13hAqkS/

you need a ';' at the end of your class
example:
1
2
3
4
class Foo
{
     some stuff
}; //<<------------------ 


your constructor should have two arguments year and string Car(int, string, int); should be Car(int, string);

Car::Car(int y, stringm,) the second parameter doesn't have a type and if you look closely you will see a ',' that doesn't belong try this Car::Car(int y, string stringm)
Last edited on
I think "stringm" was supposed to be "string m"
Topic archived. No new replies allowed.