[正确就结贴]BCB中使用一个pas单元中的类,如何new一个实例

dreamnyj 2007-03-09 10:26:40
因为最近一直在用delphi写东西,但还有BCB下的旧的工程,所以新写了一个类,为了考虑以后的重用(可以在delphi中使用),将这个pas单元加入到bcb中,自动的编译出了头文件,但现在这个类,我搞不清楚如何在bcb中new一个实例出来。
望指教。

//PAS单元在delphi中调试编译都很正常,而且没有在PAS中使用构造和析构函数


BCB工程头文件
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
private: // User declarations

public:
TXpComputerName *CurComputerName; // 在这里定义了指针 __fastcall TForm1(TComponent* Owner);
};


下面是BCB自动生成的pas头文件内容

TXPComputerName单元
头文件
// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'XPComputerName.pas' rev: 6.00

#ifndef XPComputerNameHPP
#define XPComputerNameHPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Windows.hpp> // Pascal unit
#include <Registry.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit

//-- user supplied -----------------------------------------------------------

namespace XpComputerName
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TXpComputerName;
class PASCALIMPLEMENTATION TXpComputerName : public System::TObject
{
typedef System::TObject inherited;

private:
……… //具体函数声明省略
public:
……… //具体函数声明省略
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TXpComputerName(void) : System::TObject() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TXpComputerName(void) { }
#pragma option pop

};


//-- var, const, procedure----------------------------------------

} /* namespace Xpcomputername */
using namespace XpComputerName;
#pragma option pop // -w-
#pragma option pop // -Vx

#pragma delphiheader end.
//-- end unit ----------------------------------------------------
#endif // XPComputerName




我在窗体的OnCreate事件下

CurComputerName = new TXPComputerName();

错误信息如下:
[C++ Error] Unit1.cpp(23): E2303 Type name expected
[C++ Error] Unit1.cpp(23): E2034 Cannot convert 'int *' to 'TXpComputerName *'
[C++ Error] Unit1.cpp(23): E2379 Statement missing ;




我该如何声明这个实例
...全文
369 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Leighf 2007-06-04
  • 打赏
  • 举报
回复
mark
Joininthefun 2007-03-11
  • 打赏
  • 举报
回复
mark
ytfhwfnh 2007-03-10
  • 打赏
  • 举报
回复
mark
dreamnyj 2007-03-09
  • 打赏
  • 举报
回复
休息了一会 ,又编译了一下,竟然通过了。。。

我看生成的 临时文件全都删除了,,TDS那个预编译头文件也删除了。就行了。。。真晕

感谢楼上回复
CACACACACA 2007-03-09
  • 打赏
  • 举报
回复
除了NEW, 不知道别的了.

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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