C++中的静态成员错误 [英] Static member error in c++

查看:33
本文介绍了C++中的静态成员错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 C++ 中定义一个静态成员指针.但是我收到链接器错误.错误是

I am trying to define a static member pointer in C++. However I get a linker error. The error is

1>main.obj : error LNK2001: unresolved external symbol "public: static class Activity * * Solution::temp" (?temp@Solution@@2PAPAVActivity@@A)

1>Solution.obj : error LNK2001: unresolved external symbol "public: static class Activity * * Solution::temp" (?temp@Solution@@2PAPAVActivity@@A)

代码:

class Solution{

public:
    Activity **solution;

    Solution();
    Solution(Activity **list, bool direction);
    static Activity** temp;
};

Activity 是另一个类.我该如何解决这个问题?

Activity is another class. How can I solve this problem?

推荐答案

你必须添加定义:

Activity** Solution::temp = 0;

到实现类解决方案的文件.

to the file that implements the class Solution.

这篇关于C++中的静态成员错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆