sridhar@ksuvax1.cis.ksu.edu (Srinivasan Sridhar) (07/10/89)
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 <stream.h> 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