 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Will Oram Guest
|
Posted: Tue Sep 30, 2003 12:30 am Post subject: Implementation Files & C++ |
|
|
Normally I use PB for Cocoa, but now I'm using it for a school project.
I have an implementation file, a header, and a main cpp file.
I have a class defined in the header, which I will simplify to the
basics for viewing audiences:
class SomeClass {
public:
SomeClass(); //constructor
};
...with function members defined in the implementation:
SomeClass::SomeClass() {
cout << "hellon";
}
Trouble is, PB complains that I've already defined SomeClass elsewhere.
It doesn't *show* me where, though.
I've tried this in CodeWarrior too, with similar complaints. Now I'm
thinking it's my fault and not a compiler quirk. But I essentially
copied the above out of my textbook!
Any thoughts? Thanks.
|
|
| Back to top |
|
 |
Attila Feher Guest
|
Posted: Tue Sep 30, 2003 7:25 am Post subject: Re: Implementation Files & C++ |
|
|
Will Oram wrote:
[SNIP]
| Quote: | Trouble is, PB complains that I've already defined SomeClass
elsewhere. It doesn't *show* me where, though.
I've tried this in CodeWarrior too, with similar complaints. Now I'm
thinking it's my fault and not a compiler quirk. But I essentially
copied the above out of my textbook!
Any thoughts? Thanks.
|
I have no idea what PB is, but what I am sure about is that you need to post
a minimal, compilable code what shows your problem. With this information
we could only guess.
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
--
Attila aka WW
|
|
| Back to top |
|
 |
Howard Guest
|
Posted: Tue Sep 30, 2003 4:11 pm Post subject: Re: Implementation Files & C++ |
|
|
| Quote: | Normally I use PB for Cocoa, but now I'm using it for a school project.
I have an implementation file, a header, and a main cpp file.
I have a class defined in the header, which I will simplify to the
basics for viewing audiences:
class SomeClass {
public:
SomeClass(); //constructor
};
..with function members defined in the implementation:
SomeClass::SomeClass() {
cout << "hellon";
}
Trouble is, PB complains that I've already defined SomeClass elsewhere.
It doesn't *show* me where, though.
I've tried this in CodeWarrior too, with similar complaints. Now I'm
thinking it's my fault and not a compiler quirk. But I essentially
copied the above out of my textbook!
Any thoughts? Thanks.
|
What do your #include's look like? Perhaps you're including the header
twice in the same compilation unit. If so, you can fix that by putting the
following lines (or something similar) around the contents of your header
file:
#ifndef h_myclass
#define h_myclass
// rest of header file contents here...
#endif
-Howard
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|