C++ template in Objective C++
Vector3D.h
template(class Type) class cMVector3D
{
public:
Type x;
Type y;
Type z;
public:
//--------------------------------
// @breif: Constructor
//--------------------------------
cMVector3D(): x(0), y(0), z(0) {};
//--------------------------------
// @breif: Destructor
//--------------------------------
~cMVector3D() {};
};
main.mm --- if your program is objective c hybrid with c++, you need to rename your file ext. from *.m to *.mm.
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
cMVector3D(float)
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
Reference:
http://hi.baidu.com/184367426/blog/item/4324263a5ac76e2f71cf6c7c.html
Comments
Post a Comment