ここで何をしているのかわからないので、教科書からサンプルコードをコピーして自分のプログラムの情報に置き換えることをたくさん行っています...しかし、このエラーの原因を教えてください?
車.cpp
// Implementation file for the Car class
#include "Car.h"
// This constructor accepts arguments for the car's year
// and make. The speed member variable is assigned 0.
Car::Car(int carYearModel, string carMake)
{
yearModel = carYearModel;
make = carMake;
speed = 0;
}
// Mutator function for the car year
void Car::setYearModel(int carYearModel)
{
carYearModel = yearModel;
}
// Mutator function for the car make
void Car::setMake(string carMake)
{
carMake = make;
}
車.h
// Specification file for the Car class
#ifndef CAR_H
#define CAR_H
#include <string>
using namespace std;
class Car
{
private:
int yearModel; // Car year model
string make; // Car make
int speed; // Car speed
public:
Car(int, string); // Constructor
// Mutators
void setYearModel(int);
void setMake(string);
};
#endif
main.cpp
#include <iostream>
#include <iomanip>
#include <string>
#include "Car.h"
using namespace std;
int main()
{
// Create car object
Car honda(int yearModel, string make);
// Use mutator functions to update honda object
honda.setYearModel(2005);
honda.setMake("Accord");
return 0;
}
これらは私が得ているエラーです:
エラー C2228: '.setYearModel' の左側にはクラス/構造体/共用体が必要です
エラー C2228: '.setMake' の左側にはクラス/構造体/共用体が必要です