public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* error: redefinition of `class Array<T>'
@ 2003-10-27 20:30 Paulo Cortes
  0 siblings, 0 replies; 2+ messages in thread
From: Paulo Cortes @ 2003-10-27 20:30 UTC (permalink / raw)
  To: gcc-help

Hi

I am building an Array group of classes, I have base Array class with
derived vector, matrix and cube. Each derived class works fine separately,
but if I combine them in a program I get:

error: redefinition of `class Array<T>'

this happend beacuse when I :

#include <vector.h>
#include <matrix.h>
#include <cube.h>


array.h get included too, so the compiler triggers the error. The 
problem is that I have to include
array.h into the matrix, vector and cube header files in order to use 
the array base class.
Any help would be apprecciated. Many thanks

Paulo

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: error: redefinition of `class Array<T>'
@ 2003-10-27 20:36 lrtaylor
  0 siblings, 0 replies; 2+ messages in thread
From: lrtaylor @ 2003-10-27 20:36 UTC (permalink / raw)
  To: cortes, gcc-help

Paulo,

Do you have #ifndef statements in your array.h header file so that it
only gets included once?  For example, should do something like this in
array.h (in all of your header files, actually):

#ifndef ARRAY_H
#define ARRAY_H

<array.h stuff goes here>

#endif

That way, the preprocessor will only process your header file once per
source file, even if it gets included by more than one other header file
that you're including in your program.

Make sense?

Cheers,
Lyle

-----Original Message-----
From: Paulo Cortes [mailto:cortes@uiuc.edu] 
Sent: Monday, October 27, 2003 4:33 PM
To: gcc-help@gcc.gnu.org
Subject: error: redefinition of `class Array<T>'

Hi

I am building an Array group of classes, I have base Array class with
derived vector, matrix and cube. Each derived class works fine
separately,
but if I combine them in a program I get:

error: redefinition of `class Array<T>'

this happend beacuse when I :

#include <vector.h>
#include <matrix.h>
#include <cube.h>


array.h get included too, so the compiler triggers the error. The 
problem is that I have to include
array.h into the matrix, vector and cube header files in order to use 
the array base class.
Any help would be apprecciated. Many thanks

Paulo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-27 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-27 20:30 error: redefinition of `class Array<T>' Paulo Cortes
2003-10-27 20:36 lrtaylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).