#include <iostream>
using namespace std;
class Assn2
{
public:
static void set_numberofshape();
static void increase_numberofshape();
private:
static int numberofshape22;
};
void Assn2::increase_numberofshape()
{
numberofshape22++;
}
void Assn2::set_numberofshape()
{
numberofshape22=0;
} // there is a problem with my static function declaration
int main()
{
Assn2::set_numberofshape();
}
为什么undefined reference to Assn2::numberofshape22
编译时会出错?
我正在尝试声明一个静态整数:numberofshape22 和两种方法。
方法 1 将 numberofshapes22 增加 1
方法2将numberofshape22初始化为0
我究竟做错了什么 ??