类型转换的问题

wingfootedtiger 2005-09-11 05:39:57
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TStrings *pSerList;
TStrings *pModeList;
ReadPhysicalDrive(pSerList,pModeList);
Edit1->Text=pSerList->Strings[0] //这里出错
Edit2->Text=pModeList->Strings[0] //这里出错
}

ReadPhysicalDrive函数的原型是:
void __fastcall ReadPhysicalDrive(TStrings *pSerList, TStrings *pModeList);

请问怎么解决呢?怎么才能让Edit1里正确显示?

...全文
97 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
XBox360 2005-09-13
  • 打赏
  • 举报
回复
不知道你ReadPhysicalDrive函数里面的内容
不过从外面来看
指针没有指向内存
rainfall19831109 2005-09-12
  • 打赏
  • 举报
回复
楼主...看你的代码...
好像还没对pSerList和pModeList分配内存啊...
ThinkX 2005-09-12
  • 打赏
  • 举报
回复
pSerList和pModeList没有被new出来啊。
EagleFew 2005-09-12
  • 打赏
  • 举报
回复
没错,没有建立TStrings对象,你只是定义了这个类的指针而已


TStrings *pSerList;
TStrings *pModeList;

换成

TStrings *pSerList=new TStrings();
TStrings *pModeList=new TStrings();



wingfootedtiger 2005-09-11
  • 打赏
  • 举报
回复
也不行,头疼啊
huzhangyou 2005-09-11
  • 打赏
  • 举报
回复
TStrings contains pure virtual methods
TStrings 含有纯虚函数,不能那样使用
你可以使用TStringList看看
TStringList是从TStrings继承过来的

TStringList *pSerList;
TStringList *pModeList;
ReadPhysicalDrive(pSerList,pModeList);
Edit1->Text=pSerList->Strings[0] ;
Edit2->Text=pModeList->Strings[0] ;
wingfootedtiger 2005-09-11
  • 打赏
  • 举报
回复
编译没有问题,运行到那一步就出错,不知道该怎么写,各位帮忙
signed 2005-09-11
  • 打赏
  • 举报
回复
跟踪一哈噻,这里面没有类型转换的问题

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧