0

I can't identify the problem can somebody help me?

objects.h (abstract base)

#ifndef objects_h
#define objects_h

#include "colorScreen.h"
#include "maincontrol.h"
#include <ctime> #include <string>
using namespace std;

class objects
{
public:
	virtual ~objects();
	virtual void print(const MainControl &inMain)const =0; 
protected:
	objects();
	objects(const int& inX, const int& inY,const int&inScore);
...

13.(missing type specifier - int assumed. )


food.h (derived)

#ifndef food_h
#define food_h

#include <iostream>
#include "objects.h"

using namespace std;

class food: public objects 
{
public:
	food(const int&inX, const int&inY, const int&inScore); 
	virtual ~food();
	virtual void print(const MainControl &inMain)const;
...

9. ('objects' : base class undefined)
14. (missing type specifier - int assumed. )

maincontrol.h

#ifndef maincontrol_h
#define maincontrol_h

#include <iostream> #include <fstream> #include <string> #include <vector>
#include "food.h"
#include "colorScreen.h"
using namespace std;

class objects;

class MainControl
{
public:
	MainControl(...);
	void print(const MainControl &in) const;
	friend objects; 
...

I frd MainControl with objects here

can anyone identify the problem? Thanks!

2
Contributors
5
Replies
9
Views
8 Years
Discussion Span
Last Post by alexhkleung
0

The code you posted isn't very useful. Check for missing semicolons, especially at the end of the class declaration

class object
{
<snip>
};

Looks like the problem may be in the way you have the header files included.

food.h >> objects.h >> maincontrol.h >> food.h

So nothing is fully defined. Try adding class forward references.

0

i have }; for all three classes
what else could have caused the problem?

0

another problem

i want to frd the MainControl with the derived class food too

class objects;
class food;
class MainControl
{
public:
friend objects;
friend food;
...
};

MainControl::MainControl(char x)
{
switch(x)
{
case 'f': pointer = new food(...);break;
...
}
}

15. error C2514: 'food' : class has no constructors

is the error caused by my way of friending MainControl with a derived class?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.