Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compiler won't recognize class def 1

Status
Not open for further replies.

PlasmaZero

Programmer
Dec 6, 2002
13
US
I'm trying to compile a set of classes I wrote. Most seem to compile OK, but two out of the 10 or so won't compile at all. These two are derived from a class, which is a child, etc, and they are at the end of the inheritance. I checked several times for an extra semicolon or something that would prevent them from being recognized as class definitions, but I can't find anything. The compiler simply gives tons of errors: "_____ missing storage-class or type specifiers". Here's one of the class headers:

#if !defined(TRACK)
#define TRACK

#include "seq.h"
#include "util.h"
#include "soundgen.h"

class Track : public Seq
{
public:
Track();
Track(SoundGen inst);
~Track();

double output_sample();

SoundGen get_Instrument() {return instrument;}
void set_Instrument(SoundGen sg) {instrument = sg;}

double get_Gain() {return gain;}
void set_Gain(double newgain) {gain = newgain;}

// Note manip
void addNote(Note note);
void removeNote(int index);
void insertNote(int index, Note note);
Note getNote(int index);

private:
SoundGen instrument;
Notes notes;
double gain;
};

#endif // TRACK

The files included by this compile fine, which are laid out in the same structure.
When this file (track.h) is included, the compiler gives tons of syntax errors, things like missing semicolons which I know isn't the case. I have no idea why it won't compile this, I've looked over it many times by now and don't see anything wrong with it. I'd appreciate any thoughts.

Thanks
 
With formal definitions of (empty) classes Note, SoundGen et al this header was compiled OK (VC++ 6.0). See your seq.h etc...
Use Track(const SoundGen& inst), not a SoundGen arg by value. But it's the other story...
 
Hmm. seq.h and soundgen.h don't have any issues. One thing that I'm thinking could be causing this is that class Notes is defined in util.h, but util.h defines a Tracks collection as well (requiring class Track to be working). Would this interdependency cause the compiler to throw errors?
 
Yes, of course.
Sometimes you may predeclare class:
Code:
class Track;
... then use Track*, for example,
but don't use its members, sizeof etc...
 
2 things, youre not using managed c++ are you? and you arent cyclicly referencing a class are you?

eg:

class a
{
private:
b* pMyB;
}

class b
{
private:
a* pMyA;
}

?

Skute

"There are 10 types of people in this World, those that understand binary, and those that don't!"
 
I've got it sorted out now. I was cyclicly #including class definitions.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top