Create an object Packman * P = New Packman () in the Game class. But gives out 3 errors in this place:
1) unforeseen lexemes before;
2) There is no type specifier – assumed int. C++ does not support int the default
3) syntactic error: no “;” Before “*”
game.cpp
#Pragma OCE
#ifndef Game_h.
#Define Game_h.
#Include "Packman.h"
#Include "constants.h"
#Include "ghost.h"
#Include "Pellet.h"
# INCLUDE & LT; Memory & GT;
Class Pacman;
Class Game.
{
Public:
Game ();
void start ();
void startloop ();
void Loadfield ();
void printdownload ();
CHAR GETFIELD (Int Y, Int X);
void eatpellet (int y, int x, char c);
Private:
Packman * p = New Packman ();
Char Field_ [FIELD_HEIGHT] [FIELD_WIDTH];
};
main.cpp.
# INCLUDE & LT; IOSTREAM & GT;
#Include "Game.h"
INT MAIN ()
{
Game * Game = New Game ();
Game- & gt; start ();
Return 0;
}
Tell me please, what’s wrong?
Answer 1, Authority 100%
Actually incomprehensible, where your Game.h
…
but for now – here
packman * p = new packman ();
The compiler must know what Packman ()
is, i.e. Have Full Ad Class Packman
. And it is just not …
If you hoped the presence of a line
class pacman;
then this is an incomplete ad (until you led the code in "packman.h"
– it remains to assume that there is nothing, the file is empty, and it is limited to the fact that there is … what question is – Such and answer :)).
And this incomplete ad is not at all the class packman
, and Pacman
.
But even if the correct name was indicated there – then use
= new packman ();
You still have no right – without a full class ad.