Advertisement

including problems

Started by October 04, 2002 05:06 PM
3 comments, last by OshEcho 22 years, 1 month ago
hi, im a beginer with c++ and i believe that i am doing something wrong with how i include files. i think that its included in the wrong spot or order. here are the 2 errors i get: e:\myprojects\softlife\textstuff.cpp(5) : error C2084: function ''void __cdecl clrscr(void)'' already has a body e:\myprojects\softlife\textstuff.cpp(23) : error C2084: function ''void __cdecl gotoxy(short,short)'' already has a body here is my small sorce:
  
//-------SoftLife.cpp---------

#include "Global.h"

int main(int argc, char* argv[])
{
	clrscr();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 
    FOREGROUND_GREEN | FOREGROUND_INTENSITY);

	gotoxy(5, 5);

	cout << "test";

	return 0;
}
//---------------------------


//-------TextStuff.cpp-------

#include "Global.h"

void clrscr(void)
{ 
    ...
}

void gotoxy(short x, short y) //Were int

{ 
    ...
}
//---------------------------


//---------Global.h----------

#ifndef GLOBALS_H
#define GLOBALS_H

#include <windows.h> 
#include <iostream.h>

#include "SoftLife.h"
#include "TextStuff.h"

#endif
//----------------------------


//--------SoftLife.h----------

#include "TextStuff.cpp"
//----------------------------


//--------TextStuff.h---------

void clrscr();
void gotoxy(short x, short y);
//----------------------------

  
does anyone have any ideas on what i am doing wrong?? TIA -Echo
-Echo
You''re doing a lot of things wrong
Read Kylotan''s article..


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
hmm,
well, have have now read that article 2 times. once before i posted, and i still cant see what i did wrong and how to fix it. im sure its some/many simple thing. can u tell me exactly what i did wrong and how to fix it?
-Echo
-Echo
Wow. That is an incredibly convoluted string of inclusions. I think the problem is that you don''t understand the concept of #include, and you should definitely read up on it.

Are clrscr() and gotoxy() functions you wrote? If so, why do their bodies consist of nothing but an ellipse? If not, you definitely need to learn how to use libraries properly. In any case, you should not be including a .cpp file. And why on earth do you need three .h files that all include each other? There''s something fundamentally wrong with what you''re doing.
ah,
thats what it was, the including of the .cpp
thanx a lot.

-Echo
-Echo

This topic is closed to new replies.

Advertisement