Creating simple Menu system

I have to create a menu system for a mock video game. The user has to be able to input his/her name, a car & track (both selected from images), number of AI in race. It uses a curser system.

These are the classes I have come up with so far, but I am reciving multiple error messages:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//DRplayername.h
#ifndef _DRPLAYERNAME_H_
#define _DRPLAYERNAME_H_

#include "DRplayername.h"

class CPlayerName {

public:
	
	PlayerName();
	char getName();	
	void setName(int newValue);

protected:
	char name;

};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//DRplayername.cpp
#include "DRplayername.h"

Player::Player(){

}

char Player::getName(){

    return Name;

}

void Player::setName(int newName){

    Name = newName;

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//DRcarselection.h
#ifndef _DRCARSELECTION_H_
#define _DRCARSELECTION_H_

#include "DRcarselection.h"

class CCarSelection {

public:
	
	CarSelection();
	int getCar();	
	void setCar(int newValue);

protected:
	int car;

};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//DRcarselection.cpp
#include "DRcarselection.h"

Car::Car(){

}

int Car::getCar(){

    return Car;

}

void Car::setCar(int newValue){

    Car = newCar;

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//DRtrackselection.h
#ifndef _DRTRACKSELECTION_H_
#define _DRTRACKSELECTION_H_

#include "DRtrackselection.h"

class CTrackSelection {

public:
	
	TrackSelection();
	char getTrack();	
	void setTrack(int newValue);

protected:
	int track;

};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//DRtrackselection.cpp
#include "DRtrackselection.h"

Track::Track(){

}

char Track::getTrack(){

    return Track;

}

void Track::setTrack(int newTrack){

    Track = newTrack;

}


Please help me figure out how to structure the classes. Thank You in Advance
gtfc wrote:
I am reciving multiple error messages

What are they?
Let's start with CTrackSelection .

Since the class is called CTrackSelection the forward declaration of the functions must be the same so instead of :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Track::Track(){

}

char Track::getTrack(){

    return Track;

}

void Track::setTrack(int newTrack){

    Track = newTrack;

}


you should have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CTrackSelection::CTrackSelection(){

}

char CTrackSelection::getTrack(){

    return track;

}

void CTrackSelection::setTrack(int newTrack){

    track = newTrack;

}


also you should declare the CTrackSelection::CTrackSelection() constructor in the header .

so I guess that would become :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//DRtrackselection.h
#ifndef _DRTRACKSELECTION_H_
#define _DRTRACKSELECTION_H_

class CTrackSelection {

public:
	
	CTrackSelection();
	char getTrack();	
	void setTrack(int newValue);

protected:
	int track;

};

#endif  


also, you can't include a header that you haven't defined yet and I don't see why you would include #include "DRtrackselection.h" in DRtrackselection.h . Headerception .

Furthermore, why do you have int track; protected and not private ? do you plan on inheriting the track class ?

Try to repair all files in the same manner , maybe it helps :)
Last edited on
Topic archived. No new replies allowed.