为什么main函数里b.print()会出错?
#include <iostream>
#include <string>
using namespace std;
class netuser {
private:
string id, email, code;
public:
netuser() {
this->id = "无名氏";
this->code = "出错啦";
this->email = id + "@gpnu.edu.cn";
ntotalnumber++;
}
netuser(string id, int code) {
this->id = id;
this->code = code;
this->email = email;
ntotalnumber++;
}
static int ntotalnumber;
static void printotal();
void print();
};
int netuser::ntotalnumber = 0;
void netuser::printotal() {
cout << "用户数:" << ntotalnumber << endl;
}
void netuser::print() {
cout << " " << id << " " << code << " " << email << endl;
}
int main()
{
netuser a( "JJ.Lin", 123);
a.printotal();
a.print();
netuser b();
b.printtotal();
b.print();
return 0;
}