Sunday, July 12, 2009

C++ Error Using Multiple Files?

Hi!! I'm using Qt 4.2.3, C and C++, and I have these files and their headers:


1. main.cpp:


#include %26lt;QApplication%26gt;


#include "window.h"


#include "register.h"





2. window.h


#ifndef WINDOW_H


#define WINDOW_H


#include %26lt;QWidget%26gt;





3. window.cpp


#include %26lt;QtGui%26gt;


#include %26lt;stdio.h%26gt;


#include %26lt;string.h%26gt;


#include %26lt;stdlib.h%26gt;


#include %26lt;cstdlib%26gt;


#include "client.c"


#include "register.h"


#include "window.h"





4. register.h


#ifndef PRINCIPAL_H


#define PRINCIPAL_H


#include %26lt;QWidget%26gt;





5. register.cpp


#include %26lt;QtGui%26gt;


#include %26lt;stdio.h%26gt;


#include %26lt;string.h%26gt;


#include %26lt;stdlib.h%26gt;


#include %26lt;cstdlib%26gt;


#include "client.c"


#include "principal.h"


#include "window.h"





6. client.c


#include %26lt;stdio.h%26gt;


#include %26lt;sys/types.h%26gt;


#include %26lt;sys/socket.h%26gt;


#include %26lt;netinet/in.h%26gt; ... etc








When I compile it, I get an error, the compiler complains that these


names are all duplicates. How can I fix it?


In register.cpp and window.cpp I need to use procedures of client.c





Thanks!!!!!

C++ Error Using Multiple Files?
What are you doing, including other source files?





If you need to use functions that are present in other source file, create a header file that declares the existence of those functions, and then include the header file.


No comments:

Post a Comment