qq_45735316
qq_45735316
采纳率80.7%
2020-04-04 22:33 阅读 96

为什么老是报错啊啊啊啊啊啊啊?

图片说明
main.cpp

#include <iostream>

#include "ClassStudent.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    Student a(1,'m','m');
    Student::showCount();
    return 0;
}

ClassStudent.cpp

#include "ClassStudent.h"
using namespace std;
    int Student::count=0;
    void Student::showCount()
    {
        cout<<count<<endl;
    }

ClassStudent.h

class Student{
    public:
        Student(int num=0,char name='a',char sex='f'):num(num),name(name),sex(sex){
            count++;
        }
        static void showCount();
    private:
        int num;
        char name;
        char sex;
        static int count;
};
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    zx289544730 zx289544730 2020-04-05 20:03

    ClassStudent.cpp里增加

    #include <iostream>
    
    点赞 评论 复制链接分享

相关推荐