2 phase constructor
来源:互联网 发布:咸鱼是淘宝网二手吗 编辑:程序博客网 时间:2024/05/29 19:05
class CStudent : public CBase
...{
public:
static CStudent* NewLC(const TDesC& aName, TInt aNum);
static CStudent* NewL(const TDesC& aName, TInt aNum);
TInt GetNum() const ...{ return iNum; }
const TDesC& GetName() const ...{ return *iName; }
CStudent& operator=(const CStudent& aStu);
static TInt CompareByNum(const CStudent& aStu1, const CStudent& aStu2);
~CStudent();
private:
CStudent(TInt aNum);
void ConstructL(const TDesC& aName);
private:
HBufC* iName;
TInt iNum;
};
CStudent* CStudent::NewLC(const TDesC& aName, TInt aNum)
...{
CStudent* self = new(ELeave) CStudent(aNum);
CleanupStack::PushL(self);
self->ConstructL(aName);
return self;
}
CStudent* CStudent::NewL(const TDesC& aName, TInt aNum)
...{
CStudent* self = NewLC(aName, aNum);
CleanupStack::Pop(self);
return self;
}
CStudent::CStudent(TInt aNum) : iNum(aNum) ...{ }
void CStudent::ConstructL(const TDesC& aName)
...{
iName = aName.Alloc();
}
TInt CStudent::CompareByNum(const CStudent& aStu1, const CStudent& aStu2)
...{
if (aStu1.GetNum() == aStu2.GetNum())
return 0;
else
return aStu1.GetNum() > aStu2.GetNum() ? 1 : -1;
}
CStudent& CStudent::operator =(const CStudent& aStu)
...{
iNum = aStu.GetNum();
delete iName;
iName = aStu.GetName().Alloc();
return *this;
}
CStudent::~CStudent()
...{
delete iName;
iName = NULL;
}
LOCAL_C void MainL(const TDesC& aArgs)
...{
_LIT(KTom, "Tom");
_LIT(KJack, "Jack");
CStudent* stu = CStudent::NewLC(KTom, 21);
CStudent* other = CStudent::NewLC(KJack, 33);
*stu = *other;
console->Printf(stu->GetName());
console->Printf(_L("%d"), stu->GetNum());
CleanupStack::PopAndDestroy(other);
CleanupStack::PopAndDestroy(stu);
}
...{
public:
static CStudent* NewLC(const TDesC& aName, TInt aNum);
static CStudent* NewL(const TDesC& aName, TInt aNum);
TInt GetNum() const ...{ return iNum; }
const TDesC& GetName() const ...{ return *iName; }
CStudent& operator=(const CStudent& aStu);
static TInt CompareByNum(const CStudent& aStu1, const CStudent& aStu2);
~CStudent();
private:
CStudent(TInt aNum);
void ConstructL(const TDesC& aName);
private:
HBufC* iName;
TInt iNum;
};
CStudent* CStudent::NewLC(const TDesC& aName, TInt aNum)
...{
CStudent* self = new(ELeave) CStudent(aNum);
CleanupStack::PushL(self);
self->ConstructL(aName);
return self;
}
CStudent* CStudent::NewL(const TDesC& aName, TInt aNum)
...{
CStudent* self = NewLC(aName, aNum);
CleanupStack::Pop(self);
return self;
}
CStudent::CStudent(TInt aNum) : iNum(aNum) ...{ }
void CStudent::ConstructL(const TDesC& aName)
...{
iName = aName.Alloc();
}
TInt CStudent::CompareByNum(const CStudent& aStu1, const CStudent& aStu2)
...{
if (aStu1.GetNum() == aStu2.GetNum())
return 0;
else
return aStu1.GetNum() > aStu2.GetNum() ? 1 : -1;
}
CStudent& CStudent::operator =(const CStudent& aStu)
...{
iNum = aStu.GetNum();
delete iName;
iName = aStu.GetName().Alloc();
return *this;
}
CStudent::~CStudent()
...{
delete iName;
iName = NULL;
}
LOCAL_C void MainL(const TDesC& aArgs)
...{
_LIT(KTom, "Tom");
_LIT(KJack, "Jack");
CStudent* stu = CStudent::NewLC(KTom, 21);
CStudent* other = CStudent::NewLC(KJack, 33);
*stu = *other;
console->Printf(stu->GetName());
console->Printf(_L("%d"), stu->GetNum());
CleanupStack::PopAndDestroy(other);
CleanupStack::PopAndDestroy(stu);
}
- 2 phase constructor
- C++ 2-phase lookup
- Threading in C#, phase 2
- CONFIGURING OSPF IN PHASE 2 DMVPN NETWORK
- 分布式事物-2PC(Two-Phase Commit)
- Constructor
- Constructor
- constructor
- constructor
- constructor
- constructor
- constructor
- mt6735[Call] USSD是否支持USSD Phase 1 & 2 2
- Away3D in Flex 4 – Phase 2 – Positioning components
- 两段提交协议(Two Phase Commit Protocol--2PC)
- CSAPP3e - x86-64 assembly code analysis - Bomb Lab: phase 2
- Two-phase commit(2PC) 协议介绍/以及疑问
- Phase Conjugation
- 函数式编程另类指南
- 财富与眼光
- 为什么我在别人面前签名时手会颤抖?
- 关于转载Spring 的MVC I18N-国际化相关配置出现的问题
- windows核心编程6
- 2 phase constructor
- ext2概述
- java语法学习
- 数据库语句大全之查询控件
- 深入浅出UMDF(1)
- 在数据窗口itemchanged事件中改变自身值
- Eclipse WTP 插件安装
- linux操作之:设置系统启动时,自动启动一些程序,或者执行一些命令
- 元宵-红酒汤圆