|
|
|
|
![]() ![]() |
Jun 14 2005, 08:53 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
I'm using Dev-C++ as a compiler.
(To use a classroom assignment as an example,) here is my problem...I've got classes Dog and Cat, which inherit from class Animal, (which uses iostream, stdlib, and some classes created by students) When I include both Dog and Cat in a new file, I get errors because I'm including libraries twice. (iostream included from Dog, and from Cat...)I can get around the problem by having Dog inherit Animal, and Cat inherit Dog (which sounds pretty idiotic, I know..I was just testing to see if the problem was really what I thought it was...) This is all on a PC at school, and I'm out for the summer, so I can't include the specific code...Please post if I'm not explaining myself well enough. Thanks! |
|
|
|
Jun 15 2005, 01:50 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 142 Joined: 24-December 04 From: Queensland, Australia Member No.: 2,902 |
I always include whatever libraries are necessary for the class/file to compile fine without depending on other custom files.
So, anything that might need the iostream header, will have it included... My only thought is that you haven't included the ifndef around the classes: #ifndef DOG_H #define DOG_H #include <iostream> #include "animal.h" class Dog : public Animal { }; #endif I just did a test dummy up, and it worked fine. QUOTE This is all on a PC at school, and I'm out for the summer, so I can't include the specific code...Please post if I'm not explaining myself well enough. You know, it's not really that hard to bump up a test case to recreate the problem. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 2nd December 2008 - 11:15 AM |