C++类定义语法
C++ Class definition syntax
当我尝试编译以下代码时,出现错误:
"include/IBCppClient/client/SoftDollarTier.h|3|error: variable 'TWSAPIDLLEXP SoftDollarTier' 具有初始值设定项但不完整的类型|"。
我想代码是正确的,因为它是股票经纪人 API 的一部分。但我很难理解关于类定义的部分"class TWSAPIDLLEXP SoftDollarTier"
.据我所知,这种语法在C++是不合法的。我错过了什么?
class TWSAPIDLLEXP SoftDollarTier{
std::string m_name, m_val, m_displayName;
public:
SoftDollarTier(const std::string& name = "", const std::string& val = "", const std::string& displayName = "");
std::string name() const;
std::string val() const;
std::string displayName() const;
};
C++允许宏定义,这允许 C 预处理器基本上查找这些宏并将其替换为更复杂的定义。C/C++ 中的常见做法是使用预处理器宏在其名称之前插入函数属性,可能发生的情况是您的环境不包含定义TWSAPIDLLEXP
的头文件,因此编译器将字符串解释为类名。
从快速搜索来看,似乎TWSAPIDLLEXP
在tws-api中定义为:
#define TWSAPIDLLEXP __declspec(dllimport)
在IBJts/samples/Cpp/TestCppClient/StdAfx.h
.
相关文章:
- 单独定义模板化嵌套类方法的正确语法
- 共享指针和具有自定义删除程序的唯一指针之间的语法差异背后的任何原因
- C++使用 rand 定义函数语法
- 在标准中,模板参数的语法在哪里定义,例如,'std::function<int(char)>'?
- 创建具有验证和语法突出显示的自定义 printf
- C++类定义语法
- C++定义/赋值语法
- 标准库中的任何正则表达式语法是否支持 (?(定义)用于子模式参考?
- 带有自定义类的共享指针语法背后的任何原因,如下所示
- 在语法树中的节点上定义的层次结构的表达式模板
- OpenCV - Ptr 语法和类定义/声明 - 混淆?
- 为什么C++没有简洁的语法允许在不定义计数器的情况下多次执行操作?
- 通过该类中定义的指针调用类方法时的语法
- 如何在源文件中定义类并将其声明在标题文件中(而不必使用`class :: method'语法定义类方法)
- 是C 中的语法错误,以结束与A}的类定义中的函数
- Linux正确的语法将通过config传递libstdc 的自定义目录
- 将变量定义为数组和正确的语法
- 使用自定义对象的地图使用MAP?可能是语法问题
- 你能解释一下这个C++函数定义的语法吗?
- 语法意外失败提升::精神语法定义