我正在尝试为游戏编写一些代码,但我不断收到8行错误消息,并在“插入正在说的内容之前”始终说“Expected'=',',',';','asm'或'attribute”关于这里”

它很烦人,我不知道为什么。这是代码:

class Vec2 **"error here before Vec2"**
{
public:

float X, Y;

Vec2() {}
Vec2(const float &x, const float &y) :
  X(x),
  Y(y)
{
};

float &operator[] (const int &index)
{
    switch (index)
    {
    case 0:
        return X;
    case 1:
        return Y;
    }

    throw Exceptions::IndexOutOfRange();
};

float *operator & ()
{
    return &X;
};
};

template<> class TypeInfo<Vec2> : public TypeInfo_Atomic<Vec2> {}; **"error here before <"**


class Vec3 **"error here before Vec3"**
{
public:

float X, Y, Z;

Vec3() {}
Vec3(const float &x, const float &y, const float &z) :
  X(x),
  Y(y),
  Z(z)
{
};

float &operator[] (const int &index)
{
    switch (index)
    {
    case 0:
        return X;
    case 1:
        return Y;
    case 2:
        return Z;
    }

    throw Exceptions::IndexOutOfRange();
};

float *operator & ()
{
    return &X;
};
};

template<> class TypeInfo<Vec3> : public TypeInfo_Atomic<Vec3> {}; **"error here before <"**

class Vec4 **"error here before Vec4"**
{
public:

float X, Y, Z, W;

Vec4() {}
Vec4(const float &x, const float &y, const float &z, const float &w) :
  X(x),
  Y(y),
  Z(z),
  W(w)
{
};

float &operator[] (const int &index)
{
    switch (index)
    {
    case 0:
        return X;
    case 1:
        return Y;
    case 2:
        return Z;
    case 3:
        return W;
    }

    throw Exceptions::IndexOutOfRange();
};

float *operator & ()
{
    return &X;
};
};

template<> class TypeInfo<Vec4> : public TypeInfo_Atomic<Vec4> {}; **"error here before <"**



class Color **"error here before Color"**
{
public:

byte R, G, B, A;

Color() {}
Color(byte r, byte g, byte b, byte a) :
  R(r),
  G(g),
  B(b),
  A(a)
{
};

byte *operator & ()
{
    return &R;
};

static const Color      Red,
                        Green,
                        Blue,
                        Yellow,
                        White,
                        Black;
};

template<> class TypeInfo<Color> : public TypeInfo_Atomic<Color> {}; **"flag here before <"**

总共有8个错误。帮助将不胜感激!

最佳答案

如果要将Objective-c和c++代码放入同一文件,则需要使用.mm文件扩展名。

http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html

关于iphone - 为什么这会不断出错?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9968892/

10-12 17:17