Newsgroups: comp.lang.c++ Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Is a struct a class? Message-ID: <1988Oct9.224128.26585@utzoo.uucp> Organization: U of Toronto Zoology References: <449@usl.usl.edu> Date: Sun, 9 Oct 88 22:41:28 GMT In article <449@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes: >From the readings, I was under the impression that a struct in C++ >is a class. Yes. > X = new X; >bombs in AT&T C++ on 3B2/Sys V. Any comments? Did you declare the variable X before using it? With the proper type, which is "X *" (since "new X" returns pointer-to-X)? What you have written is an assignment statement, not a declaration. Also, note that one major difference between C++ and C is that a class declaration in C++ implicitly does a typedef as well, which means using the same name for a variable and a type is a bad idea. Try making it "X *Y = new X;". -- The meek can have the Earth; | Henry Spencer at U of Toronto Zoology the rest of us have other plans.|uunet!attcan!utzoo!henry henry@zoo.toronto.edu