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.

#import "MVector3D.h"

int main(int argc, char *argv[]) {
   
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   
    cMVector3D(float)  testV;   ~~~template success
          
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;


Reference:
http://hi.baidu.com/184367426/blog/item/4324263a5ac76e2f71cf6c7c.html

Comments

Popular posts from this blog

Drawing textured cube with Vulkan on Android

glTF loader for Android Vulkan

C++ unit testing & CI integration in GitHub (I/2)