加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c如何获取对象的类型?

发布时间:2020-12-16 09:34:41 所属栏目:百科 来源:网络整理
导读:我如何获得以下类型:T宾语;其中T是:template class T.我在使用c代码.我做了测试: const std::type_info ObjT= typeid(object);std::cout"******the objT is: "ObjTstd::endl; 但它崩溃了.为什么? 解决方法 你有没有包括: #include typeinfo 也许你应该
我如何获得以下类型:T&宾语;其中T是:template< class T>.我在使用c代码.我做了测试:

const std::type_info& ObjT= typeid(object);
std::cout<<"******the objT is: "<<&ObjT<<std::endl;

但它崩溃了.为什么?

解决方法

你有没有包括:

#include <typeinfo>

也许你应该发送

std::cout << typeid(object).name() << std::endl;

也许你正在做&&和在对象上.

看一下here的例子

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读