gpt4 book ai didi

C++:错误:在 ';' token 之前应为 '<'

转载 作者:太空宇宙 更新时间:2023-11-04 15:21:11 24 4
gpt4 key购买 nike

我在 C++ 代码中遇到错误

error: using-declaration for non-member at class scope"
error: expected ';' before '<' token

使用这段代码:

struct Entry { 
char* word;
char* def;
}

class Dictionary {
public:
Dictionary();
~Dictionary();
void addEntry(Entry*);
char* getDef(const char*);

private:
std::vector<Entry> dict; //Error happens here
}

这个错误是什么意思?

最佳答案

你忘记了一些分号:

struct Entry { 
char* word;
char* def;
}; //C++ structs need a semicolon after the curly brace.


class Dictionary {
public:
Dictionary();
~Dictionary();
void addEntry(Entry*);
char* getDef(const char*);

private:
std::vector<Entry> dict;

};

关于C++:错误:在 ';' token 之前应为 '<',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18898608/

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