No suitable constructor?!?!
Sorry guys, but this is ........ing me off and i've got no clue how to fix it. It's coming up in 4 different codes. Maybe if I get one, the others will make sense.
Code:
//Chapter 6 Debug 1
#include<iostream>
#include<conio.h>
using namespace std;
class Auto
{
public:
int autoId;
char mechanicName[20];
double fee;
void Auto1(int id, char name[], double amt);
//switched above line with Auto1 function, above line initialized variables and added void
void showAuto();
};
void Auto::Auto1(int id = 999, char name[], double amt = 25.00)
{
autoId = id;
strcpy(mechanicName, name);
fee = amt;
}
void Auto::showAuto()
{
cout<<"Auto #"<<autoId<<" worked on by "<<mechanicName<<" Amount due $"<<fee<<endl;
}
void main()
{
cout<<"Mike's Service "<<endl<<"Autos Worked on Today"<<endl<<endl;
cout<<"Mike works on most cars. Occasionally he assigns a job to another mechanic"<<endl;
cout<<"Minimum charge $25"<<endl<<endl;
Auto car1, car2(321), car3(456,"Amy"), car4(567,"Jeremy",149);
car1.showAuto();
car2.showAuto();
car3.showAuto();
car4.showAuto();
std::cin.clear();
std::cin.ignore();
getchar();
}
no suitable constructor exists to convert from "int" to "Auto" shows up for the numbers at the bottom: car2(321), car3(456,...), car4(567, ........).
I'm getting this for an error message:
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(16): error C2548: 'Auto::Auto1' : missing default parameter for parameter 2
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(31): error C2440: 'initializing' : cannot convert from 'int' to 'Auto'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(31): error C2078: too many initializers
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(31): error C2440: 'initializing' : cannot convert from 'const char [4]' to 'Auto'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(31): error C2078: too many initializers
1>c:\users\m0531098\documents\visual studio 2010\projects\debug 6\debug 6\debug 6.cpp(31): error C2440: 'initializing' : cannot convert from 'int' to 'Auto'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
Help if you can. Thanks.