Jump to content
  • Advertisement
Sign in to follow this  
wioneo

Class Problems

This topic is 2953 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

I have..

#include "c_app.h"
//blabla...
class c_control
{
public:

c_control(c_app *curr_app);
~c_control();

c_app *o_app;
c_piece *o_piece;
//blabla
};





...and in 'c_app.h' there is a 'c_app' class, but VS is giving me these(among several other) syntax errors...

1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.
(26): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(29): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int




...why is this?

I'll add the entire header files below...
[hide]
c_control.h

//
#pragma once

#include "c_app.h"
#include "c_piece.h"
#include <sdl_gfxprimitives.h>

//customization
#define BOARD_WIDTH 20
#define BOARD_HEIGHT 40
#define PIECE_BLOCKS 5
#define BLOCK_SIZE 32
#define DROP_RATE 32

//colors
#define C_BOARD 0x000000ff//black
#define C_LINE 0xB0B0B0ff//gray
#define C_BLOCK_NORMAL 0x0000FFff//blue
#define C_BLOCK_PIVOT 0xEEEE00ff//yellow
#define C_BLOCK_STORED 0x000033ff//dark blue
#define C_BLOCK_STORED2 0xEEAD0Eff//dark yellow
#define C_BLOCK_GAMEOVER 0xFFFFFFff//white

class c_control
{
public:

c_control(c_app *curr_app);
~c_control();

c_app *o_app;
c_piece *o_piece;

//values
int px, py, ptype, prot;
int next_px, next_py, next_ptype, next_prot;
int board_x, board_y;
int storage[BOARD_WIDTH][BOARD_HEIGHT];//locked pieces 0=empty 1=full
int line_combo;//multiple lines cleared at once
int score;

//functions
void ini_board();
void clear_board();
void new_piece();
void store_piece();
void draw_board();
void draw_piece(int px,int py,int ptype,int prot);
void check_lines();
void clear_line(int ly);
bool can_move(int px,int py,int ptype,int prot);
};





c_app.h

//
#pragma once

#include "c_events.h"
#include "c_surface.h"
#include "c_control.h"

class c_app : public c_events, public c_surface
{
bool app_running;
public:
c_app();
~c_app();

c_app *o_app;
c_control *o_control;

bool ini_app();
int run_app();
void update_app();
void draw_screen();
void ini_cleanup();

void ev_exit();
void ev_keydown(SDLKey sym, SDLMod mod, Uint16 unicode);

};





c_piece.h

//
#pragma once

class c_piece
{
public:

c_piece();
~c_piece();

int get_block_type(int ptype, int prot, int px, int py);
int get_xoff(int ptype, int prot);
int get_yoff(int ptype, int prot);
};





[/hide]

and here is the full error list...
[hide]

1>------ Build started: Project: tetris2, Configuration: Debug Win32 ------
1>Build started 7/17/2010 8:53:29 PM.
1>InitializeBuildStatus:
1> Touching "Debug\tetris2.unsuccessfulbuild".
1>ClCompile:
1> updates.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> main.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\main.cpp(24):
error C2664: 'c_control::c_control(const c_control &)' : cannot convert
parameter 1 from 'c_app **' to 'const c_control &'
1> Reason: cannot convert from 'c_app **' to 'const c_control'
1> No constructor could take the source type, or constructor overload
resolution was ambiguous
1> initialization.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1> events.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1> draw_screen.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1> cleanup.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(28): error C2061: syntax error : identifier 'c_app'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_control.h
(31): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1> c_control.cpp
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_app.h(16):
error C2143: syntax error : missing ';' before '*'
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_app.h(16):
error C4430: missing type specifier - int assumed. Note: C++ does not support
default-int
1>c:\documents and settings\owner\desktop\cpp\tetris2\sdl_base\c_app.h(16):
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.03
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




[/hide]

EDIT: I'll check the faq for how to do hide tags properly...

Share this post


Link to post
Share on other sites
Advertisement
Good point. But he'll still have to fix the cyclic include. (And his misconceptions about the role of inheritance, but baby steps.)

Share this post


Link to post
Share on other sites
Thank you, Sneftel, adding 'class' specifiers fixed the problem.(about the semi-colon, I forgot to include it when typing in the browser but that wasn't in the program).

Feel free to clear up my misconceptions by the way! I would hate to find out that I've messed up horribly somewhere down the road.

EDIT: Also, how can I declare an identifier for a class without actually creating an object? I want a way for all member functions to know the object, but it is created in one of them. The way that I'm doing it now is to have a pointer declared in the ehader and then set the poitner to the object after it's created, but I don't think this is the best way.

[Edited by - wioneo on July 17, 2010 10:10:59 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!