
一直报错试了很久还是不行严重性 LNK2019 无法解析的外部符号 "class StationWagon __cdecl s(void)" (?s@@YA?AVStationWagon@@XZ),函数 main 中引用了该符号 14.2 C:\Users\myself\Desktop\c++\第十四周作业\14.2\14.2\源.obj 1
#include
using namespace std;
class Automobile {
public:
Automobile(string a, string b, int c, int d) :brand(a), colour(b), weight(c), power(d) {
cout << "Automobile con" << endl;
}
void A_set(string a, string b, int c, int d){
brand = a;
colour = b;
weight = c;
power = d;
}
void A_show() {
cout << "品牌:" << brand << endl;
cout << "颜色:" << colour << endl;
cout << "车重:" << weight << "kg"<
}
private:
string brand;
string colour;
int weight;
int power;
};
class Car :virtual public Automobile{
public:
Car(string a, string b, int c, int d, int e) :Automobile(a, b, c, d) {
seat = e;
cout << "Car con" << endl;
}
void C_set(string a, string b, int c, int d,int e) {
Automobile::A_set( a, b, c, d);
seat = e;
}
void C_show() {
Automobile::A_show();
cout << "座位数:" << seat << endl;
}
private:
int seat;
};
class Wagon :virtual public Automobile{
public:
Wagon(string a, string b, int c, int d, int e) :Automobile(a, b, c, d) {
load = e;
cout << "Wagon con" << endl;
}
void W_set(string a, string b, int c, int d, int e) {
Automobile::A_set(a, b, c, d);
load = e;
}
void W_show() {
Automobile::A_show();
cout << "载重:" << "kg"<
private:
int load;
};
class StationWagon :public Car, public Wagon {
public:
StationWagon(string a, string b, int c, int d, int e, int f) :Automobile(a,b,c,d), Car(a, b, c, d, e), Wagon(a, b, c, d, f) {
cout << "StationWagon con" << endl;
}
void S_set(string a, string b, int c, int d, int e,int f) {
Car::C_set(a, b, c, d,e);
Wagon::W_set(a, b, c, d, f);
}
void S_show() {
Car::C_show();
Wagon::W_show();
}
};
int main() {
StationWagon s();
s().S_set("宝马","黑色",2400,340,7,545);
s().S_show();
return 0;
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)