佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1413|回复: 4

C++ 高手请进。。。

[复制链接]
发表于 5-11-2009 10:38 PM | 显示全部楼层 |阅读模式
各位高手知不知道如何把一个pointer of list pass from 一个process 到另一个process (in C++ DCOM)?

eg:
int * pIntList = NULL;

pIntList = new int[3];  or pIntList = CoTaskMemAlloc(3*sizeof(int))
pIntList[0] = 1;
pIntList[1] = 2;
pIntList[2] = 3;

pass to another process:
client->assOut(&pIntList );

为什么我在另一个process只能得到第一个的value, 其他的都corrupted.
在同一个process就可以得到完。
回复

使用道具 举报


ADVERTISEMENT

发表于 5-11-2009 10:55 PM | 显示全部楼层
client->: PassOut(&pIntList[ i ] );


应该要这样的

&pIntList 就等于 &pIntList[0] 而已,所以只有第一个value对


[ 本帖最后由 水果rojak 于 5-11-2009 10:58 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 7-11-2009 09:01 AM | 显示全部楼层

回复 2# 水果rojak 的帖子

只能把address of pointer pass in to the function (&pIntList)
应为 PassOut(int ** list)

我试过如果用在同一个process 就没问题所有的value都可以读。
回复

使用道具 举报

发表于 8-11-2009 05:24 PM | 显示全部楼层
原帖由 水果rojak 于 5-11-2009 10:55 PM 发表
client->: PassOut(&pIntList[ i ] );


应该要这样的

&pIntList 就等于 &pIntList[0] 而已,所以只有第一个value对


&pIntList 跟 &pIntList[0] 没分别,除非有operator override
回复

使用道具 举报

发表于 8-11-2009 05:26 PM | 显示全部楼层
原帖由 nokiro 于 7-11-2009 09:01 AM 发表
只能把address of pointer pass in to the function (&pIntList)
应为 PassOut(int ** list)

我试过如果用在同一个process 就没问题所有的value都可以读。


http://cforum1.cari.com.my/viewthread.php?tid=1776350&extra=page%3D1
dynamically allocated object stored on heap,
一个process 的pointer 不可以搬到另一个去用
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 2-12-2025 08:17 AM , Processed in 0.108658 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表