Constructors giving me a hard time

I have a class Car that calculates speed and whatnot, but with the constructor im getting error messages bugging me to no end.

1
2
3
4
5
6
Car::Car(string carMake, int carYear)
{
	make = carMake;
	year = carYear;
	setYear(year);
}


This is my constructor
Under the second 'Car' i get the message "no instance of overloaded function "Car::Car" matches the specified type.

later in my main() i have

Car carOne(make, year);
under 'make' i get the message "no instance of constructor "Car::Car" matches the argument list. Argument types are:(std::string, int)

Also when i try to build my project i get these messages

1>c:\users\kyle\documents\visual studio 2012\project\source.cpp(33): error C2511: 'Car::Car(std::string,int)' : overloaded member function not found in 'Car'
1> c:\users\kyle\documents\visual studio 2012\project\source.cpp(8) : see declaration of 'Car'
1>c:\users\kyle\documents\visual studio 2012\project\source.cpp(103): error C2661: 'Car::Car' : no overloaded function takes 2 arguments


Any ideas where i went wrong?
Last edited on
class visibility is private by default. If you have not declared your constructor within the public scope, then your constructor is not visible.
Oh i see.

I had it like this before

1
2
3
4
5
6
7
8
Class Car
{
Private:
//all my variables
Public:
//all my functions
};
Car::Car


So i just put Car::Car inside the public. and it seemed to work for now. Thanks progrady
Topic archived. No new replies allowed.