Почему это продолжает давать ошибки? - PullRequest
1 голос
/ 02 апреля 2012

Я пытаюсь кодировать некоторые вещи для игры, но я получаю сообщения об ошибках в 8 строках, в которых постоянно говорится "Ожидаемый" = ",", ", ';'," 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 ошибок.Помощь будет высоко ценится!

Ответы [ 2 ]

3 голосов
/ 02 апреля 2012

Если вы помещаете кодjective-c и c ++ в один и тот же файл, вам нужно использовать расширение файла .mm.

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

2 голосов
/ 02 апреля 2012

Он не считает ваш модуль C ++.Какой суффикс вы дали файлу?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...