2012-08-24 58 views
0

我有一個QR碼Signature類我希望把記錄語句和我開始用構造部分爲:QRCodeSignature類不允許記錄語句

QRCodeSignature::QRCodeSignature(std::vector<WacomType::PEN>* theSigpoints, int theInterval, int theVersion) : sigpoints(theSigpoints), interval(theInterval), version(theVersion) { 
Logging::log(QRCodeSignature::logger, Logging::Entry, QRCodeSignature::CLASSNAME, "QRCodeSignature"); 

我在QRCodeSignature.cpp以下包括

#include "QRCodeSignature.h" 
    #include <iostream> 
    #include <cstdlib> 
    #include <stdio.h> 
    #include <stdlib.h> 
    #include <math.h> 

在QRCodeSignature.hi已經得到了下面的類作爲QRCodeSignature

a constructor 
    a virtual destructor 
    private: 
    static const std::string CLASSNAME; 
    static Logging::Logger* logger; 

在QRCodeSignature.cpp我有

const std::string CLASSNAME = "QRCodeSignature"; 
Logging::logger* QRCodeSignature::logger = NULL; 

的錯誤,當我建立這個項目[發佈]

build/Release/MinGW_1-Windows/QRCodeSignature.o: In function `QRCodeSignature': 
C:\repos\impression\trunk\ProsenseSign/QRCodeSignature.cpp:13: undefined reference to `QRCodeSignature::CLASSNAME' 
collect2: ld returned 1 exit status 
make[2]: *** [dist/Release/MinGW_1-Windows/impression.api] Error 1 
make[1]: *** [.build-conf] Error 2 
make: *** [.build-impl] Error 2 

回答

0

您應該使用,而不是

const std::string QRCodeSignature::CLASSNAME = "QRCodeSignature"; 

const std::string CLASSNAME = "QRCodeSignature"; 

自第二次我不是初始化類的static-member