Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!unmvax!deimos.cis.ksu.edu!ksuvax1.cis.ksu.edu!sridhar From: sridhar@ksuvax1.cis.ksu.edu (Srinivasan Sridhar) Newsgroups: comp.lang.c++ Subject: Multiple Definitions in Headers Message-ID: <2283@deimos.cis.ksu.edu> Date: 10 Jul 89 05:38:36 GMT Sender: news@deimos.cis.ksu.edu Reply-To: sridhar@ksuvax1.cis.ksu.edu (Srinivasan Sridhar) Distribution: usa Organization: Kansas State University, Dept of Computing & Information Sciences Lines: 44 I have been having the following problems with my C++ 1.2. When I try to use a new object of type x, say, that has been defined in a header file called x.h. 1. Initialized a vector of the class objects in main program segment (function main.c). //main.c #include "x.h" #include main() { x* x1 = new x[10]; ..... .. } 2. Declared x as extern in another file (fun.c) //fun.c #include "x.h" fun() { extern x x1; x1[0] = x(..ctor); } Now, when I do this, it passes thro' the compilation phase and when it comes to the loading phase, complains of : 1. Undefined x1 2. x being multiply defined (x is overloaded in x.h) (this is after a few ifndef statements in the header and .c files to avoid multiple inclusions of x.h) Any solutions or suggestions to use objects defined in .h files? If stream.h should work, I don't see why my header file structured in the same manner shouldn't. Thanks in advance for help. You can e-mail suggestions to my address: sridhar@ksuvax1.cis.ksu.edu