• Advertisement

Class stays blind

This topic is 2773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey!

I´m currently working on a Load/Save Routine and got it working quite fine already..
here is a part of the code:

IO.h
#ifndef _IO_H_#define _IO_H_#include "globals.h"#include "Writer.h"class IO {public:	IO(string filename);	string iofile;		bool SaveWriter(Writer &refData);	bool LoadWriter(Writer &refData);};#endif

Writer.h
#ifndef _WRITER_H_#define _WRITER_H_#include "globals.h"#include "IO.h"#include "Dialog.h"class Writer{public:	Writer();			{...}};#endif

when compiling i get
... IO.h(12): error C2061: syntax error : identifier 'Writer'

what did i do wrong... the longer i program in cpp the less i know how to do what ^^ -.-

thanks for yout time and help,
jan

Share this post

Share on other sites
Advertisement
looks like your files are getting confused as they are tryinging to link to each other. Try removing

#include "Writer.h"

and replace it with

class Writer;

Share this post

Share on other sites
Organizing Code Files in C and C++ covers breaking up circular #includes on page 3 some.

It's often a good idea to try to break up such cycles in the code itself, however -- having two classes depend on each other makes them hard or impossible to test or debug individually. Just something to keep in mind for the future.

Share this post

Share on other sites
Maybe as both files include each other try

#pragma once

Share this post

Share on other sites
thanks a lot... I was able to solve the problem now :D

jan

Share this post

Share on other sites

• Advertisement
• Advertisement
• Popular Tags

• Advertisement
• Popular Now

• 10
• 12
• 10
• 10
• 11
• Advertisement