gpt4 book ai didi

c++ - QRCodeSignature类不允许记录语句

转载 作者:行者123 更新时间:2023-12-02 11:05:53 24 4
gpt4 key购买 nike

我有一个QRCode Signature类,我希望放置日志记录语句,我从构造函数部分开始如下:

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.h中,我得到了以下类作为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

最佳答案

你应该用

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

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

因为第二个不是类的 static-member的初始化。

关于c++ - QRCodeSignature类不允许记录语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12103645/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com