开发者

error C2146 and C4430

开发者 https://www.devze.com 2023-03-24 06:05 出处:网络
First: sorry my bad English =(( Sencond: here\'s my code in \"Global.h\": #pragma once class GlobalVariable

First: sorry my bad English =((

Sencond:

here's my code in "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;

};


and I have some eror :(

------ 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 d开发者_JAVA技巧efault-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 ==========

But after I delete the GlobalVariable class! Only class Point, Color, DaGiac, Circle exist! It has no eror! Tell me why? And how to corect that error ? Please =((


The compiler can't "see" the other classes, because they're defined after the GlobalVariable class. Move the whole GlobalVariable class to the bottom of the file so that all of the classes it depends on will be defined when it needs them.

0

精彩评论

暂无评论...
验证码 换一张
取 消