声明中的类型太多 [英] Too many types in declaration

查看:73
本文介绍了声明中的类型太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在学习C ++,我写了一个包含这些文件的小项目:


Log.h

Log.cpp


Render.h

Render.cpp


Tid.h
Tid.cpp


________________________

在TID.h:


#ifndef TID_HPP_INCLUDED

#define TID_HPP_INCLUDED


typedef unsigned char byte;


......

#define EXIT_SUCCESS 0

.....

#define BGI_DRIVER" SVGA64K"

#define BGI_600_480 4
#define SCREEN_WIDTH 600

....

#define LOG_FILE_NAME" log.txt"


#include< graphics.h>

#include< stdlib.h>

#include< conio.h>

#include < dos.h>

#include< mem.h>

#include< stdio.h>


#include" Log.h"

#include" MouseLib.h"

#include" Render.h"


#endif


------------ -----------------------

TID.CPP


#include" TiD.h


int main(无效)

{

...........

返回EXIT_SUCCESS;

}


___________________

在LOG.hi中有:

#ifndef LOG_HPP_INCLUDED

#define LOG_HPP_INCLUDED


void CLog_write(const char * s);

#endif


________________________________

Log.CPP


#include" TID.h"

void CLog_write(const char * s){../ * writewrite file * / ...}

---------------- --------------------------------------

Render.H

#include" tid.h"


#ifndef RENDER_ENGINE_HPP

#define RENDER_ENGINE_HPP


typedef struct tagBITMAP {

.....} BITMAP;

class CRender

{

public:

CRender();

~CRender();

void fskip(FILE * fp,int) ;

......

私人:

......

}


---------------------------------------- -----------------

RENDER.CPP


#include" TID.h"


//初始化图形模式。

CRender :: CRender()

{

/ * init BGI驱动程序* /

}


void CRender :: PutImage(const char * filename,int x,int y,int ops)

const

{

FILE * fp;

....

CLog_write(" CRender) :: PutImage():无效的BMP文件);

.....

}

....


------------------------------------------ --------------


当我在TC ++ 3.0中编译时,我有错误信息:

错误LOG.CPP 3 :声明中的类型太多。

我认为问题可能与包括标题有关。但在我用

1文件(和一个标题)编写简单程序之前,我不太了解可能的文件和许多标题。


感谢您的帮助。

TLE

解决方案

tienlx写道:




我正在学习C ++,我写了一个包含这些文件的小项目:


Log.h

Log.cpp


Render.h

Render.cpp


Tid.h

Tid.cpp


________________________

在TID.h:


#ifndef TID_HPP_INCLUDED

#define TID_HPP_INCLUDED


typedef unsigned char byte;


.....

#define EXIT_SUCCESS 0

....

#define BGI_DRIVER" SVGA64K"

#define BGI_600_480 4

#define SCREEN_WIDTH 600

...

#define LOG_FILE_NAME" log.txt"


#include< graphics.h>

#include< stdlib.h>

#include< conio.h>

#include< dos.h>

#include< mem.h>

#include< stdio.h>


#include" Log.h"

#include" MouseLib.h"

#include" Render.h"


#endif


------------------------- ----------

TID.CPP


#include" TiD.h"


int main(无效)

{

...........

返回EXIT_SUCCESS;

}


___________________

在LOG.hi中有:

#ifndef LOG_HPP_INCLUDED

#define LOG_HPP_INCLUDED


void CLog_write(const char * s);


#endif


________________________________

Log.CPP

#include" TID.h"


void CLog_write(const char * s){../*写文件* / ...}


-------------------------------------- ----------------

渲染.H

#include" tid.h"

#ifndef RENDER_ENGINE_HPP

#define RENDER_ENGINE_HPP


typedef struct tagBITMAP {

....} BITMAP;


级CRender

{

public:

CRender();

~CRender();

void fskip(FILE * fp,int);

.....

private:< br $> b $ b .....

}


----------------- ----------------------------------------

RENDER。 CPP


#include" TID.h"


//初始化图形模式。

CRender :: CRender()

{

/ * init BGI驱动程序* /

}


void CRender :: PutImage(const char * filename,int x,int y,int ops)

const

{

FILE * fp;

...

CLog_write(" CRender :: PutImage():无效的BMP文件"); < br $> b $ b ....

}

...


------- -------------------------------------------------


当我在TC ++ 3.0中编译时,我有错误消息:

错误LOG.CPP 3:声明中的类型太多。


我认为问题可能与包括标题有关。但在我用

1文件(和一个标题)编写简单程序之前,我不太了解可能的文件和许多标题。


感谢您的帮助。



没什么好说的。请参阅发布代码的指南:

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.8


发布一个最小但是*完整*示例我们可以复制并粘贴

不变为我们的编辑器以查看您获得的错误。 (请注意,我们

没有非标准的标题,如graphics.h,dos.h或conio.h。)


干杯! --M


mlimber写道:


tienlx写道:


>我正在学习C ++,我写了一个包含这些文件的小项目:



[...]


> -------------- ----------------------------------------
Render.H #include" tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP {
....} BITMAP;

类CRender
{
公开:
CRender();
~CRender();
void fskip(FILE * fp,int );
.....
私人:
.....
}



^^^^

这里似乎缺少分号。


>>



[...]


>

什么都没有突出。



这是真的,它并不是真的坚持......


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问




mlimber在留言中写道...


> tienlx写道:


>
我正在学习C ++,我写了一个包含这些文件的小项目:
________________________
在TID.h中:
#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;
.....



到OP:


#ifdef EXIT_SUCCESS

#undef EXIT_SUCCESS


> #define EXIT_SUCCESS 0



#endif / / #ifdef EXI T_SUCCESS


> ....
...
#define LOG_FILE_NAME" log.txt" ;

#include< graphics.h>
#include< stdlib.h>
#include< conio.h>
#include< dos .h>
#include< mem.h>
#include< stdio.h>



也许张贴到''C''NG? < G>

或....


//> #include< stdlib.h>

# include< cstdlib>


//> #include< conio.h>

//> #include< dos.h>

//> #include< mem.h>

#include< memory>


//># include< stdio.h>

#include< cstdio>


> --- -------------------------------------------------- ---



-

Bob R

POVrookie


Hi,
I''m learning C++, i wrote a small project that has these files:

Log.h
Log.cpp

Render.h
Render.cpp

Tid.h
Tid.cpp

________________________
In TID.h :

#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;

......
#define EXIT_SUCCESS 0
.....
#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define SCREEN_WIDTH 600
....
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>

#include "Log.h"
#include "MouseLib.h"
#include "Render.h"

#endif

-----------------------------------
TID.CPP

#include "TiD.h"

int main(void)
{
...........
return EXIT_SUCCESS;
}

___________________
In LOG.h i have:
#ifndef LOG_HPP_INCLUDED
#define LOG_HPP_INCLUDED

void CLog_write(const char *s);
#endif

________________________________
Log.CPP

#include "TID.h"

void CLog_write(const char* s){ ../*write file*/... }
------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
.....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
......
private:
......
}

---------------------------------------------------------
RENDER.CPP

#include "TID.h"

// Initialize graphic mode.
CRender::CRender()
{
/* init BGI driver */
}

void CRender::PutImage (const char * filename,int x,int y,int ops)
const
{
FILE *fp;
....
CLog_write("CRender::PutImage() : Invalid BMP file");
.....
}
....

--------------------------------------------------------

When i compile in TC++ 3.0 i have error message:
Error LOG.CPP 3: Too many types in declaration.
I think the problem maybe about "include header" but i don''t know much
about may files and many header, before i wrote simple programs with
1 file (and one header).

Thank for your help.
TLE

解决方案

tienlx wrote:

Hi,
I''m learning C++, i wrote a small project that has these files:

Log.h
Log.cpp

Render.h
Render.cpp

Tid.h
Tid.cpp

________________________
In TID.h :

#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;

.....
#define EXIT_SUCCESS 0
....
#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define SCREEN_WIDTH 600
...
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>

#include "Log.h"
#include "MouseLib.h"
#include "Render.h"

#endif

-----------------------------------
TID.CPP

#include "TiD.h"

int main(void)
{
...........
return EXIT_SUCCESS;
}

___________________
In LOG.h i have:
#ifndef LOG_HPP_INCLUDED
#define LOG_HPP_INCLUDED

void CLog_write(const char *s);
#endif

________________________________
Log.CPP

#include "TID.h"

void CLog_write(const char* s){ ../*write file*/... }
------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
.....
private:
.....
}

---------------------------------------------------------
RENDER.CPP

#include "TID.h"

// Initialize graphic mode.
CRender::CRender()
{
/* init BGI driver */
}

void CRender::PutImage (const char * filename,int x,int y,int ops)
const
{
FILE *fp;
...
CLog_write("CRender::PutImage() : Invalid BMP file");
....
}
...

--------------------------------------------------------

When i compile in TC++ 3.0 i have error message:
Error LOG.CPP 3: Too many types in declaration.
I think the problem maybe about "include header" but i don''t know much
about may files and many header, before i wrote simple programs with
1 file (and one header).

Thank for your help.

Nothing sticks out. See the guidelines for posting code:

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.8

Post a minimal but *complete* example that we can copy and paste
unchanged into our editors to see the error you get. (Note that we
don''t have non-standard headers like graphics.h, dos.h, or conio.h.)

Cheers! --M


mlimber wrote:

tienlx wrote:

>Hi,
I''m learning C++, i wrote a small project that has these files:

[...]

>------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
.....
private:
.....
}

^^^^
There seems to be a missing semicolon here.

>>

[...]

>
Nothing sticks out.

That''s true, it doesn''t really "stick out"...

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask



mlimber wrote in message...

>tienlx wrote:

>Hi,
I''m learning C++, i wrote a small project that has these files:
________________________
In TID.h :
#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;
.....

To OP:

#ifdef EXIT_SUCCESS
#undef EXIT_SUCCESS

>#define EXIT_SUCCESS 0

#endif // #ifdef EXIT_SUCCESS

>....
...
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>

Maybe post to an ''C'' NG? <G>
Or....

// >#include <stdlib.h>
#include <cstdlib>

// >#include <conio.h>
// >#include <dos.h>
// >#include <mem.h>
#include <memory>

// >#include <stdio.h>
#include <cstdio>

>--------------------------------------------------------

--
Bob R
POVrookie


这篇关于声明中的类型太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆