模板类 的 typename 关键字
来源:互联网 发布:标书制作软件破解版 编辑:程序博客网 时间:2024/05/24 03:37
Tells the compiler that an unknown identifier is a type.
typename identifier;
Use this keyword only in template definitions.
This keyword must be used if the name is a qualified name dependent on a template argument; it is optional if the qualified name is not dependent.
例如:
// typename.cpp
template<class T> class X
{
typename T::Y m_y; // treat Y as a type
};
例如下面的程序,不加typename 关键字会编译错误。
//-------------------------------------------------------------------
#include <QtCore/QCoreApplication>
#include <map>
template <class T>
class MySetting
{
public:
void function();
private:
T m_data;
};
//////////////////////////////////////////////////////////////////////////
template <class T>
void MySetting<T>::function()
{
typename std::map<int, T>::iterator myit; //此处要用 typename 否则qt的mingw编译提示出错。vs2008不出错
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::map<int, int>::iterator myit;
return a.exec();
}
- 模板类 的 typename 关键字
- C++ 的模板中 typename 关键字的用法
- C++模板中关键字typename与class的区别
- 类模板参数、类型traits与typename关键字
- 关键字typename的使用
- typename 关键字的用法
- C++模板(关键字template,typename)介绍
- C++ typename关键字的作用
- C++ typename关键字的作用
- 模板中typename的作用
- template关键字typename和class的区别,以及模板默认参数
- 在模板定义语法中关键字class与typename的作用完全一样。
- 关键字typename
- typename关键字
- typename关键字
- 一个关于类模板的问题 template<typename>class A
- C++类模板:模板内的typename名字将屏蔽模板外部的名字
- c++模板中的 typename 和 template 关键字用法
- Linux文件基本属性
- 目标意识与人员级别
- Android文件系统深入剖析
- 读完它,受益匪浅……
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正1
- 模板类 的 typename 关键字
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正2
- GOOGLE在没有通知的情况下封了我几个程序
- 关于对象SMON_SCN_TIME
- Ext Grid 中增加复选框并设置回填功能
- 如何编写测试用例(一)
- Android项目总结
- checkbox全选全不选
- 如何编写测试用例(二)