#include "stdafx.h"
#include <iostream>
#include <string>
usingnamespace std;
class CVehicle {
private:
string m_make;
int m_model;
public:
CVehicle::CVehicle(int s) {
SetModel(s);
SetMake(y);
}
void SetModel(int s) {
s = m_model;
}
void SetMake(string y) {
y = m_make;
}
string ReadVehicle() {
cout << "enter model";
cin >> m_make;
return m_make;
}
}
int main() // error saying main should have int type instead of 'CVehicle'
{
CVehicle CarThree();/* i am trying to read car model form user and save in carthree and than print out carthree */
CarThree().ReadVehicle();
cout << CarThree << endl;
return 0;
}
than it says no default constructor exist for class "CVehicle"
Oh, I didn't even notice that you didn't have one.
You only defined a 1-arg constructor. When another constructor besides the default constructor is defined, a default (0-arg) constructor is not created.
Either call your 1-arg constructor, or make a default constructor yourself