如何输入内部类
How to typedef an inner class
我有一个矩阵类和一个列类:
template<class T>
struct MatrixT
{
template<class T>
struct ColumnT
{
};
};
请注意,ColumnT
始终保持与MatrixT
相同的类型。
为方便我定义
typedef MatrixT<double> matrix;
由于实际上,我大部分时间都会使用double
元素。但是我也想定义columnT
类相似的内容。我尝试了
typedef MatrixT<double>::ColumnT<double> matrix::column;
但汇编失败,错误
错误 - 不允许合格名称
是否有一种实现我想要的方法?
我希望能够键入matrix::column c;
,就像我可以键入matrix m;
只需删除第二个template<class T>
template<class T>
struct MatrixT
{
struct ColumnT
{
};
};
ColumnT
应该使用与MatrixT
相同的类型,并且您的Typedef ...
typedef MatrixT<double> matrix;
...应该按照您的期望工作。
相关文章:
- 在设计 SDK 时,我是否应该在 C++ 头文件中完全隐藏内部类?
- 如何声明由多个线程调用的 C++ DLL 的内部类,而无需导出类
- 从内部类继承
- 如何将枚举类转发声明为模板化类的内部类?
- 从内部类中的方法从包含类调用方法
- 从模板化父类中的派生内部类访问受保护的成员变量
- C++模板类的内部类访问
- 使用类模板的内部类模板专用化模板
- 如何使用包含内部类的类实例有效地从内部类访问成员?
- C++ 如何在外部类中声明的内部类中使用变量
- 在C++中将内部类实现为具有名称空间的独立类有什么好处
- 参数化类的别名(或类型定义)内部类
- 从内部类的析构函数调用虚拟函数
- 如何在没有setter的情况下设置类内部类的成员变量?
- 具有相同名称的方法和内部类(错误:.. 与前面的声明冲突)
- 内部类私有成员访问和封闭的友好性
- 在C++中从内部类对象获取外部类对象
- 在它所属的模板类中使用内部类
- C++命名空间、内部类和运算符解析
- 如何输入内部类