ошибка C2146 и C4430 - PullRequest
       5

ошибка C2146 и C4430

0 голосов
/ 31 июля 2011

Первое: извините, мой плохой английский = ((

Sencond:

вот мой код в "Global.h":

#pragma once
class GlobalVariable
{
public:
    GlobalVariable(void);
    ~GlobalVariable(void);

    //------------------------------------------------
public:
    double pixelWidth;      //  do rong cua 1 pixel tren Viewport
    double pixelHeigh;      //  do cao cua 1 pixel tren Viewport

public:
    Point   oldPoint,   tempPoint;
    Circle  oldCir,     tempCir;
    DaGiac  oldDaGiac,  tempDaGiac;
    Color   oldObjColor,tempObjColor, OxyColor;

};

class Point
{
public:
    Point(void);
    ~Point(void);

    double  x,y;            // toạ độ (x,y)
};

class Color
{
public:
    Color(void);
    ~Color(void);

    double R,G,B;           // màu (R,G,B)
};

class DaGiac
{
public:
    DaGiac(void);
    ~DaGiac(void);

    int numOfPeak;  //so' dinh?
    Point peakArr[10];  //  ve da giac canh so dinh toi da la 10
};

class Circle
{
public:
    Circle(void);
    ~Circle(void);

    Point centre;
    double radius;

};


и у меня есть ошибка: (

------ Build started: Project: GAS, Configuration: Debug Win32 ------
Compiling...
GlobalVariable.cpp
e:\documents\bin\gas_project\globalvariable.h(15) : error C2146: syntax error : missing ';' before identifier 'oldPoint'
e:\documents\bin\gas_project\globalvariable.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(16) : error C2146: syntax error : missing ';' before identifier 'oldCir'
e:\documents\bin\gas_project\globalvariable.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(17) : error C2146: syntax error : missing ';' before identifier 'oldDaGiac'
e:\documents\bin\gas_project\globalvariable.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(18) : error C2146: syntax error : missing ';' before identifier 'oldObjColor'
e:\documents\bin\gas_project\globalvariable.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
e:\documents\bin\gas_project\globalvariable.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Build log was saved at "file://e:\Documents\BIN\GAS_Project\Debug\BuildLog.htm"
GAS - 17 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Но после того, как я удаляю класс GlobalVariable! Существуют только класс Point, Color, DaGiac, Circle! У него нет ошибки! Tellмне почему? И как исправить эту ошибку? Пожалуйста = ((

1 Ответ

2 голосов
/ 31 июля 2011

Компилятор не может "видеть" другие классы, потому что они определены после класса GlobalVariable. Переместите весь класс GlobalVariable в конец файла, чтобы все классы, от которых он зависит, были определены при необходимости.

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