万星星@豌豆荚 欢迎加入我们
一个吃软饭的男人!!!!!我只想写程序####
微博:http://weibo.com/wanlianwen
posts - 172,  comments - 1253,  trackbacks - 0

1、传统的C++类
      由于ACDK也是C++代码,所以在传统C++类中使用ACDK类是没有问题的
// this is a NON ACDK class
class AClass
{
    
int _val;
public:
    AClass() : _val(
42)
    
{
    }

    
// a NON ACDK class can make usage of ACDK classes.
    RString get()
    
{
        RStringBuffer sb 
= new StringBuffer();
        sb
->append(_val);
        
return sb->toString();
    }

}
;

2、类型定义
      为了获得ACDK框架的的一些特性(垃圾回收,应用于集合、反射以及脚本中等),你的类型定义需要满足以下几个条件:
     a、所有可实例化的类必须直接或者间接派生于acdk::lang::Object
     b、不运行多重继承自acdk::lang::Object
     c、接口类是纯虚类
     d、类可以实现几个接口
例如:
类定义:
ACDK_DECL_CLASS(AClass);
class AClass : extends acdk::lang::Object
{
    
int _val;
public:
    AClass(
int number) : Object(), _val(number)
    
{
    }

}
;
RAClass aclass 
= new AClass(42);

接口定义:
ACDK_DECL_INTERFACE(AInterface);
class AInterface ACDK_INTERFACEBASE
{
public:
    virtual 
void doIt(IN(RString) arg) = 0;
}
;

当然,为了利用ACDK对象模型的元特性(象序列化、垃圾回收,脚本调用),必须在类中添加元信息(Metainfo)。
posted on 2007-12-24 23:59 万连文 阅读(554) 评论(0)  编辑 收藏 引用 所属分类: ACDK

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


简历下载
联系我

<2007年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(66)

随笔分类

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜