RobotPart.h
#ifndef __ROBOTPART_H
#define __ROBOTPART_H 2016
#include <string>
class RobotPart {
public:
RobotPart(std::string kname, int kpartNumber, double kweight, double kcost,
std::string kdescription, int kpartType);
protected:
std::string name;
int partNumber;
double weight;
double cost;
std::string description;
int partType;
};
#endif
RobotPart.cpp
#include "RobotPart.h"
RobotPart::RobotPart(std::string kname, int kpartNumber, double kweight,
double kcost, std::string kdescription, int kpartType) :
name(kname), partNumber(kpartNumber), weight(kweight), cost(kcost),
description(kdescription), partType(kpartType) {}
controller.cpp
#include "controller.h"
#include "RobotPart.h"
#include "view.h"
#include "Torso.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main () {
View view;
RobotPart rb;
view.displayMenu();
return 0;
}
错误
controller.cpp: In function ‘int main()’:
controller.cpp:26:12: error: no matching function for call to ‘RobotPart::RobotPart()’
RobotPart rb;
^
controller.cpp:26:12: note: candidates are:
In file included from controller.cpp:2:0:
RobotPart.h:9:3: note: RobotPart::RobotPart(std::string, int, double, double, std::string, int)
RobotPart(std::string kname, int kpartNumber, double kweight, double kcost,
^
RobotPart.h:9:3: note: candidate expects 6 arguments, 0 provided
RobotPart.h:6:7: note: RobotPart::RobotPart(const RobotPart&)
class RobotPart {
^
RobotPart.h:6:7: note: candidate expects 1 argument, 0 provided
make: *** [controller.o] Error 1
我一直在研究关于机器人商店的c ++课程项目。我收到了这个错误,并且我试图查找类似的问题,但我似乎无法修复它。请帮忙。谢谢。