Sean's Note: 2月 2013

2013年2月18日 星期一

今天遇到了一個跟 namespace 有關的蠢問題

// A.cpp
namespace SEAN
{
    static int num;
}

// B.cpp
#include "A.h"

int num = SEAN::num; // 這行一直跑出 error C2589: '(' : illegal token on right side of '::'

搞了很久才注意到 SEAN::num 是定義在 A.cpp 而非 A.h,

想要用就要定義在 A.h 裡。