c++ - 在课堂上使用 vs typedef
问题描述
我认为using
C++11 中的新语法typedef
是等效的(模板除外)。但似乎using
也无法声明类成员。
class A {
//... Public members
private:
typedef std::vector<double> vector_double;
using vector_int = std::vector<int>;
void bar(vector_double& vecDouble); // type can be used
void foo(vector_int& vecInt); // type can't be used: synatx error
// ... Possible other private members
}
当我尝试vector_int
在 AI 类的成员函数之一中使用类型时,会出现编译器错误:syntax error: identifier 'vector_int'
.
我在这里做错了什么还是定义了一个不可能的成员类型using
?
解决方案
推荐阅读
- reactjs - 子组件中明确存在的上下文属性未定义
- c# - 为什么我不能在 input:name 中使用 @ 并在后面使用 value
- python - 在 react.js 中通过 axios 发出 POST 请求后没有得到响应
- django - 是否可以在 django 运行任何迁移命令之前创建数据库?
- swiftui - SwiftUI TextEditor 禁用自动大写
- javonet - 无法加载仅针对 64 位平台的 .net DLL
- c++ - 验证密码、ATM 程序
- google-sheets - 有什么方法可以将表格源数据分组吗?
- dbvisualizer - DBVisualizer 在包含“0001-01-01”的日期字段上显示空值
- python - 如何在 Python 中使用正则表达式从货币中提取十进制数?