栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

vs2022编译c++时出现LNK2019错误,大佬帮帮忙

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

vs2022编译c++时出现LNK2019错误,大佬帮帮忙

一直报错试了很久还是不行严重性     LNK2019    无法解析的外部符号 "class StationWagon __cdecl s(void)" (?s@@YA?AVStationWagon@@XZ),函数 main 中引用了该符号    14.2    C:UsersmyselfDesktopc++第十四周作业14.214.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"<         cout << "马力:" << power <<"匹"<< endl;
    }
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;
}

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/960184.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号