CMap或CMapPtrToPtr(CMap or CMapPtrToPtr)

   IT问题网   2021-02-19 00:00:00

问 题

嗨,

i希望将对象存储在 cmap

中我想用我的班级作为关键和价值。



比如说

  class  a {
public
cstring name;
}


现在我想在a code> cmap
所以对于这个我使用 cmapptrtoptr 。

 cmapptrtoptr map; 

a * key1 = new a();
key1-gt; name = " 1";
a * value1 = new a();
value1-gt; name = " one";
map.setat(key1,value1);

// 到目前为止没有问题,但在遍历地图时出现错误
表示
position position = map.getstartposition();
while (position!= null){
a * lo_key = new try1 ();
a * lo_value = new try1();
map.getnextassoc(位置,键,); // 这里我收到错误

}


错误是:

无法将参数2从''a *''转换为''void *amp; ''


我如何获得密钥和价值?

使用cmapptrtoptrs是正确的吗?或者还有其他方法吗?

解决方案

试试看:):

  class  a; 

typedef ctypedptrmaplt; cmapptrtoptr,a *,a *gt; cyourmap;

void someiteration(cyourmapamp; map)
{
position pos(map.getstartposition());
while (pos){
a * pakey(null); // null- 因为它确实从getnextassoc收到答案:)
a * pavalue(空值); // null- 因为它确实从getnextassoc收到答案:)
map.getnextassoc( pos,pakey,pavalue);

if (pakeyamp;amp; pavalue){
// 在这里使用答案:)
}
}
}

标签:或者



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

如何创建新的任务栏(how to create new task bar)

problem hi, i want to create new taskbar,can any one hel ...

在C#.net中旋转PDF文件(Rotate PDF File in C#.net)

problem hi , how to rotate pdf file in c#.net ...

在C#.Net中旋转图像文件(Rotate Image Files in C#.Net)

problem hi, how to rotate image files(jpeg,ti ...

如何交换字符串中的字符(how to swap characters in a string)

problem hi all. i''m new in .net and i want t ...

如何在SHAREPOINT 2010中集成twitter(How to integrate twitter in SHAREPOINT 2010)

problem hi to all, this is siddiqali working ...

检查应用程序是否正在运行(Check If Application Is Running)

problem is there a way to run a loop that wou ...

如何使用radiobuttonlist?(how to use radiobuttonlist)

problem i want to write select query for selectedindexcha ...

如何计算日期差异和数字差异(How to Calculate Date Diff And Num Diff)

problem glnotranscationdate deposit withdraw transid loan ...

ie6浏览器问题在我的网页上(ie6 browser issue in my web page)

problem my webpage displaying 1 inleft bottom corner only ...

无法在表单上使用控件。(Unable to use controls on the form.)

problem hi, i have created some static insta ...

如何在Javascript中使用正则表达式匹配定义的模式(How to match defined pattern using regular expression in Javascript)

problem hi, first, there is a string called: var bookpat ...

我想打印收据,但我遇到了问题(I want to print a reciept but i face a problem)

problem in this project i am using datareport ...

Visual Studio 2010 + Windows 7 + 64位计算机+ C ++ + 32位DLLS = 3个问题(Visual Studio 2010 + Windows 7 + 64-bit computer + C++ + 32 bit DLLS = 3 problems)

problem i''ve been using visual studio 2005 for many year ...

什么是Eclipse以及如何使用它?(What is about Eclipse and how to use it)

problem how to use it .and for what purpose it is used so ...

如何从数据库中检索数据?(how to retrieve data from database)

problem i have a radiobuttonlist control and i want to re ...

使用SQL Management Studio将数据插入我的数据库时执行NonQuery(ExecuteNonQuery while inserting the data into my database using SQL Management Studio)

problem hi i have a problem while inserting the data int ...

我如何将C#.Net中的拖放图像转换为ASP.Net(how do i convert Drag and drop image in C#.Net to ASP.Net)

problem hi, i saw the drag and drop image in c#.net arti ...

如何禁用浏览器的后退按钮(How to disable browser's back button)

problem hello friend, i am using asp.net framework 3.5,i ...

滚动后无法打印文本....(Unable to print text after scrolling....)

problem hi, i have written a small c program ...

我使用radgrid,我从数据库获取列名,但我希望他们的名称作为不同的名称,如何重命名RadGrid的列名(Im using a radgrid ,i get column names from database but i want their names as diferent names,How to rename those columns names of RadGrid)

problem im using a radgrid ,i get column names from datab ...