gpt4 book ai didi

c++ - C2059 : syntax error: constant

转载 作者:行者123 更新时间:2023-11-28 06:31:43 30 4
gpt4 key购买 nike

我无法解决第 19-23 行的 C:2059 错误。我确定我创建的 vector 数据类型是正确的。我哪里出错了?

调试器输出:C:\Qt\Tools\QtCreator\bin\Neutropenia_Application\classifier.h:21: error: C2059: syntax error : '常量'

#ifndef CLASSIFIER_H
#define CLASSIFIER_H

#include "patient_data.h"
#include <QObject>
#include <vector>
#include <stdlib.h>

class Classifier : public QObject
{
Q_OBJECT
public:
explicit Classifier(QObject *parent = 0);
~Classifier();
void classify(std::vector<patient_data>data, patient_data i);

struct CreateSDTable
{
std::vector<long> sum(3); // C2509 error //element 0 = Tumor, element 1 = Stage, element 2 = Adjuvant
std::vector<long> mean(3); // C2509 error
std::vector<long> error(3); // C2509 error
std::vector<long> SDL(3); // C2509 error
std::vector<long> SD(3); // C2509 error
};

CreateSDTable CurrentvsNeutropenic;
CreateSDTable CurrentvsNonNeutropenic;

private:
/*
std::vector<int> calculatesums(std::vector<patient_data> data, patient_data i);
std::vector<long> calculatemean(std::vector<int>validpatients, CreateSDTable Neut, CreateSDTable NonNeut);
std::vector<long>calculateerror(patient_data d, std::vector<int>m);
std::vector<long>calculatSDL(int nvp, CreateSDTable CVN, CreateSDTable CVsNN);
std::vector<int> NumofValidPatients(std::vector<patient_data>x);

//void classify(std::vector<patient_data>data, patient_data i);
*/
signals:

public slots:

};

#endif // CLASSIFIER_H

最佳答案

您不能以这种方式初始化成员变量。您需要将声明和初始化分开:

struct CreateSDTable {
std::vector<int> sum;
...
CreateSDTable() : sum(3), ... {}
};

关于c++ - C2059 : syntax error: constant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27413013/

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