我在看这个资源:
http://www.cplusplus.com/reference/vector/vector/
例如,迭代器成员类对类矢量.
一个“成员类型”是否简单地被实现为一个typedef或类似于vector类的东西?我不清楚“会员类型”实际上是什么意思,我看过几本C教科书,根本就没有提到这个短语.
解决方法
C标准也不使用这个短语.相反,它会将其称为嵌套类型名称(§9.9).
class C { public: typedef int int_type; // as a nested typedef-name using float_type = float; // C++11: typedef-name declared using 'using' class inner_type { /*...*/ }; // as a nested class or struct enum enum_type { one,two,three }; // nested enum (or 'enum class' in C++11) };
嵌套类型名称在类范围内定义,为了从外部引用它们,需要名称限定:
int_type a1; // error,'int_type' not kNown C::int_type a2; // OK C::enum_type a3 = C::one; // OK
原文地址:https://www.jb51.cc/c/114049.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。