Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Для новичков > Странная ошибка. Ругань компилятора.


Автор: nem0x 26.12.2007, 21:16
Пытаюсб разобраться с SDL. Вот исходники:
main.cpp
Код

#include <iostream>
#include "SDL.h"
#include "engine.h"

int main(int argc, char *argv[])
{
    rEngine eng = rEngine::rEngine();
    return 0;
}


engine.h
Код

#ifndef ENGINE_Z
#define ENGINE_Z
#include "scene.h"

class rEngine;

class rEngine
{
    private:
        rScene scn;
    public:
        rEngine();
}

#endif


engine.cpp
Код

#include <iostream>
#include "SDL.h"

#include "scene.h"
#include "engine.h"

rEngine::rEngine()
{
    scn = rScene::rScene();
}


scene.h
Код

#ifndef SCENE_Z
#define SCENE_Z
#include "SDL.h"

class rScene;

class rScene
{
    public:
        rScene();
}

#endif


scene.cpp
Код

#include "SDL.h"
#include "scene.h"

rScene::rScene()
{
    if( (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1) )
    {
        exit(-1);
    }
    SDL_Quit();
}


Вот. Компилятору даю такую команду:
Код

g++ -lSDL -I./source -I/usr/local/include/SDL main.cpp


А в ответ:
Код

main.cpp:5: error: new types may not be defined in a return type
main.cpp:5: note: (perhaps a semicolon is missing after the definition of ‘rEngine’)
main.cpp:5: error: two or more data types in declaration of ‘main’
main.cpp:5: error: ‘::main’ must return ‘int’


Если перед int main вставить ';', то получается другое:
Код

./source/engine.h:5: error: multiple types in one declaration


Чувствую у меня куча ошибок и неточностей. Прошу тех кто знает указать на них.

Автор: archimed7592 26.12.2007, 21:36
Цитата(nem0x @  26.12.2007,  21:16 Найти цитируемый пост)
engine.h

Цитата(nem0x @  26.12.2007,  21:16 Найти цитируемый пост)
scene.h

Точку с запятой после закрывающейся фигурной скобки определения класса ставить нужно:
Код

class C
{
};

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)