Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Realized the error of my ways Message-ID: <10625@alice.UUCP> Date: 26 Mar 90 04:47:19 GMT References: <5790@rouge.usl.edu> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 39 In article <5790@rouge.usl.edu>, ewe@gator.cacs.usl.edu (Edwin Wallace Elberson) writes: > I've got it straightened out now; I guess the problem was with my concept > of definitions and declarations. However, after seeing what I was trying to > do, does anyone have any tips on including the same header in files that > are to be compiled at the same time? Being new to C++, I'd like to see what > other people do in this situation, and how their techniques differ from > the way I'm doing it now. Thanks, The short answer is: Suppose you have a class Foo that you want to use in several separately compiled parts of your program. Create a file called Foo.h that looks like this: #ifndef Foo_flag #define Foo_flag 1 other stuff goes here #endif where `other stuff' is the class declaration itself and declarations of inline functions relevant to class Foo. Everything else that's part of class Foo goes in a separate file called Foo.c that begins this way: #include "Foo.h" and then contains definitions of member functions that aren't inline, definitions of class statics, and so on. Now you can include Foo.h in every source file that needs it without worrying about duplicate definitions, etc. -- --Andrew Koenig ark@europa.att.com