我无法使用map的迭代器调用show函数 . 有没有办法使用迭代器来做到这一点?

#include

#include

#include

using namespace std;

class A

{

int i;

public:

A(int pi):i(pi) { cout<

void show() const { cout<

~A() { cout<

};

int main()

{

map mymap;

A a(9) , b(8) , c(7);

mymap['a'] = a;

mymap['b'] = b;

mymap['c'] = c;

map::iterator it;

for(it = mymap.begin(); it != mymap.end() ; it++)

(*(it->second)).show();

return 0;

}

在使用 it->second.show() 时,我收到以下错误:

在/ usr / include / c /4.9/bits/stl_map.h:63:0中包含的文件中,来自/ usr / include / c /4.9/map:61,来自3:/ usr / include / c /4.9/元组:在实例化'std :: pair <_t1> :: pair(std :: tuple <_args1 ...>&,std :: tuple <_args2 ...>&,std :: _ Index_tuple <_indexes1 . ..>,std :: _ Index_tuple <_indexes2 ...>)[with Args1 = {char &&}; long unsigned int ... Indexes1 = {0ul}; Args2 = {}; long unsigned int ... Indexes2 = {}; _T1 = const char; _T2 = A]':/ usr / include / c /4.9/tuple:1093:63:从'std :: pair <_t1> :: pair(std :: piecewise_construct_t,std :: tuple <_args1 .. .>,std :: tuple <_args2 ...>)[with _Args1 = {char &&}; _Args2 = {}; _T1 = const char; _T2 = A]'/ usr / include / c /4.9/ext/new_allocator.h:120:4:需要'void __gnu_cxx :: new_allocator :: construct(Up *, Args && ...)[with _Up = std :: pair; _Args = {const std :: piecewise_construct_t&,std :: tuple,std :: tuple <>}; _Tp = std :: _ Rb_tree_node>]'/ usr / include / c /4.9/bits/alloc_traits.h:253:4:需要'static std :: _ Require :: __ construct_helper :: type> std: :allocator_traits :: _ S_construct(Alloc&, Tp *, Args && ...)[with _Tp = std :: pair; _Args = {const std :: piecewise_construct_t&,std :: tuple,std :: tuple <>}; _Alloc = std :: allocator >>; std :: _ Require :: __ construct_helper <_tp> :: type> = void]'/ usr / include / c /4.9/bits/alloc_traits.h:399:57:'static decltype(S_construct( a, p) ,(forward <_args>)(std :: allocator_traits :: construct :: __ args)...))std :: allocator_traits :: construct(Alloc&, Tp *, Args && ...)[with Tp = std ::对; Args = {const std :: piecewise_construct_t&,std :: tuple,std :: tuple <>}; Alloc = std :: allocator >>; decltype(S_construct( a, p,(forward <_args>)(std :: allocator_traits :: construct :: __ args)...))=]'/ usr / include / c /4.9/bits/stl_tree.h:423 :42:需要'std :: _ Rb_tree_node <_val> * std :: _ Rb_tree <_key> :: _ M_create_node( Args && ...)[with _Args = {const std :: piecewise_construct_t&,std :: tuple,std :: tuple <>}; _Key = char; _Val = std :: pair; _KeyOfValue = std :: _ Select1st>; _Compare = std :: less; _Alloc = std :: allocator>; std :: _ Rb_tree <_key> :: _ Link_type = std :: _ Rb_tree_node> *]'/ usr / include / c /4.9/bits/stl_tree.h:1790:64:'std要求:: _ Rb_tree <_key> :: iterator std :: _ Rb_tree <_key> :: _ M_emplace_hint_unique(std :: _ Rb_tree <_key> :: const_iterator, Args && ...)[with _Args = {const std :: piecewise_construct_t&,std :: tuple,std :: tuple <>}; _Key = char; _Val = std :: pair; _KeyOfValue = std :: _ Select1st>; _Compare = std :: less; _Alloc = std :: allocator>; std :: _ Rb_tree <_key> :: iterator = std :: _ Rb_tree_iterator>; std :: _ Rb_tree <_key> :: const_iterator = std :: _ Rb_tree_const_iterator>]'/ usr / include / c /4.9/bits/stl_map.h:519:8:从'std:需要: :map <_key> :: mapped_type&std :: map <_key> :: operator [](std :: map <_key> :: key_type &&) [用_Key = char; _Tp = A; _Compare = std :: less; _Alloc = std :: allocator>; std :: map <_key> :: mapped_type = A; std :: map <_key> :: key_type = char] '17:14:从这里需要/ usr / include / c /4.9/tuple:1104:70:错误:没有匹配函数来调用'A :: A()'秒(std :: forward (std :: get ( tuple2))...)^ / usr / include / c /4.9/tuple:1104:70:注意:候选人是:9:5:注意:A :: A(int)9:5:注意:候选人需要1个参数,0提供5:7:注意:constexpr A :: A(const A&)5:7:注意:候选人期望1个参数,0提供

c 调用java map_如何从C中的map迭代器调用类成员函数?相关推荐

  1. python 中的static-method (静态函数), classmethod(类函数 ), 成员函数

    python 中的static-method (静态函数), classmethod(类函数 ), 成员函数 简介 类似Java.CPP中的类,可以定义static method.class meth ...

  2. C++类成员函数在.cpp中设置成inline后无法解析的问题

    内联函数:告知编译器在进行有内联标识的函数调用时将函数体部分在调用处展开.这样做可以消除函数传参(堆栈调用)的负担,提高了函数的调用效率. 而且inlining的函数并不存在,因为已经被展开了. 如果 ...

  3. C++中空指针调用类成员函数的原理

    有下面的一个简单的类: class CNullPointCall { public:     static void Test1();     void Test2();     void Test3 ...

  4. 函数指针以及在类成员函数中应用函数指针

    什么是函数指针 如果在程序中定义了一个函数,那么在编译时系统就会为这个函数代码分配一段存储空间,这段存储空间的首地址称为这个函数的地址.而且函数名表示的就是这个地址.既然是地址我们就可以定义一个指针变 ...

  5. c++中的类成员函数指针

    c++中的类成员函数指针 文章目录 c++中的类成员函数指针 发生的事情 正常的函数指针定义 定义类的成员函数指针 std::function 发生的事情 最近,想用一个QMap来创建字符串和一个函数 ...

  6. C++类和对象(中)(6个默认成员函数)

    目录 1.类的6个默认成员函数 2. 构造函数 2.1 概念 2.2 特性 1. ==函数名==与==类名==相同. 2. 无返回值. 3. ==对象实例化时==编译器自动调用对应的构造函数. 4. ...

  7. C++中 线程函数为静态函数 及 类成员函数作为回调函数(转载)

    C++中 线程函数为静态函数 及 类成员函数作为回调函数 线程函数为静态函数: 线程控制函数和是不是静态函数没关系,静态函数是在构造中分配的地址空间,只有在析构时才释放也就是全局的东西,不管线程是否运 ...

  8. C++中的Thunk技术 / 非静态类成员函数作为回调函数 的实现方法

    申明:本文非笔者原创,原文转载自:http://www.cnblogs.com/memset/p/thunk_in_cpp.html 用我的理解通俗地解释一下什么是C++中的Thunk技术吧! Thu ...

  9. c ++类成员函数_C ++编程中的数据成员和成员函数

    c ++类成员函数 C ++中的数据成员和成员函数 (Data members and Member functions in C++) "Data Member" and &qu ...

  10. 关于类成员函数中访问同类对象的私有成员

    关于类成员函数中访问同类对象的私有成员,主要包含以下几种场景: a. 在C++的类的成员函数中,允许直接访问该类的对象的私有成员变量. b. 在类的成员函数中可以访问同类型实例的私有变量. c. 拷贝 ...

最新文章

  1. @所有人,CSDN 粉丝专属福利来啦!
  2. SDNU 1194.传纸条(DP) 1032.机器人
  3. 网管必须了解的理光复印机相关故障现相之一
  4. 阿里资深技术专家崮德:8 个影响我职业生涯的重要技能
  5. sha256加密_有加密传输数据的需求?来试试stunnel
  6. [转]rsync命令中文文档
  7. oracle 查询当年数据_查询ORACLE数据库TOP SQL使用情况
  8. 虚拟机上的linux里安装ngnix,虚拟机(linux)下安装nginx的步骤教程
  9. RDIFramework.NET(.NET快速信息化系统开发框架) Web版介绍
  10. Linux常用命令大全(持续更新)
  11. fer2013人脸表情数据实践
  12. action评测 osmo_Osmo Action与GoPro 7的七大对决,评测谁是运动相机王者?
  13. java如果文件存在则删除_Java删除文件(如果存在)的更好方法
  14. R 学习笔记《四》 R语言初学者指南--载入数据
  15. php循环语句时间戳转换,php怎么实现时间戳转换为时间
  16. 树莓派默认密码_树莓派介绍:没有显示器,怎样远程控制树莓派?
  17. conda 速度慢 解决方案
  18. cmd 控制台 提示:请求的操作需要提升!
  19. The 2019 ACM-ICPC China Shannxi Provincial Programming Contest B. Product(杜教筛+约数)
  20. 第九周课堂作业 包括建表 进行各种查询

热门文章

  1. c# webform js文件获取客户端控件,后台cs获取前台客户端控件的值,c#和js的交互...
  2. 密码管理系统竞品分析报告
  3. springboot异常处理机制之统一异常处理和自定义异常类
  4. Android开发之内容提供者ContentProvider
  5. SpringAOP原理解析
  6. 移动端车牌识别,小功能大作用
  7. Hyperledger Fabric Endorsement policies——背书策略
  8. UAC2.0 Requests处理
  9. 在服务器应用虚拟化中发现价值
  10. 【译】Matplotlib:plotting