i have been stuggling with c++, i need to compile the following files but it never works always tell me the redefinition error i have tried both g++ and visual c++ but i can't make it work, i wish anybody can tell me why here are my codes please help, i have uploaded all my files please tell me what to do.


Recommended Answers

All 4 Replies

Nobody is going to download 5 files just to help you. My suggestion is that you remove everything you can without removing the error itself (but if you do, note what you took out). Then you'll be in a better position to debug. Who knows? The code may be short enough to post here at that point.

Well, I haven't seen the files but here is my guess. The most common reason while compilation of this error is that, you include a file in one file and include the same file in some file (there is no problem so far) and after that in some other file, you include both files, now since both files contains the definations of the original file, the compiler goes through the first one and when it finds that the other file also has the same definations that the other had, then it start complaining.

I suggest to use inclusion guards (preferably in all the files, with different identifiers) and try your code, like

#ifndef _MY_HEADER_FILE_
#define _MY_HEADER_FILE_

// ... Here goes the implementations

#endif // _MY_HEADER_FILE_

If the problem persists, please post the error code with its descripition.

This invades the implementation's name space. Names with a leading underscore have a tendency to be reserved by the language definition for an implementation's use.



// ... Here goes the implementations

#endif // MY_HEADER_FILE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.