Need Help with my code

I keep running into an error with my code. It consists of three different header files and three .cpp files. It is a project I am working on in school and I need help. Also, if anyone has any idea how to do polymorphism and pointers, as I have to add them in. I can't figure out how to start in this assignment. If I need to post my header files as well I can. Thank you for any help you can offer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include "Genre.h"
#include "Game.h"
#include "Hours.h"
using namespace std;

int main ()
{
	Genre top;  // My top three genre's
	top.setName ("RPG's, Fantasy, FPS"); 
	Game game(3); // Number of genres in Constructor

	//game.setNumGames(3);
	Hours timeSpentPlaying(200);
	game.setName ("RPG-Skyrim, Fantasy-Final Fantasy, FPS-Borderlands");
	game.setHours (timeSpentPlaying);
	cout << "My top three Genre's are " << top.getName() << endl;

	cout << "How many are within this list? " <<game.getNumGames() << endl;
	cout << "What are examples of each genre? " << game.getName() << endl;

	cout << "The amount of time I spent playing each game in each genre " << game.getHours()<< "is " <<game.getHours().getHours() << endl;
	//Unsure why I keep getting an error, everything looks built right  and I can't understand why the above shows that red
	{
		system("pause");
	}

		
		return 0;


}
Show us the rest of your code in the different files. It might be something with one of your .h files.
Okay I will go ahead and set them up. Give me one moment.
This is my genre header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#ifndef GENRE_H
#define GENRE_H

#include <string>

using namespace std;

class Genre
{

private:
	string name;
public:
	string getName(); // way to get the class 
	void setName(string nm); // Set's the class
	Genre(); 
};
#endif //Ends the definition of the class 


This is my hours header.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#ifndef HOURS_H
#define HOURS_H

class Hours
{
private:
	int hours;
public:
	Hours();
	Hours(int hours);
	int getHours();
	void set(int hours);

};
#endif


and this is my game header.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#ifndef Game_H
#define Game_H

#include "Genre.h"
#include "Hours.h"

class Game : public Genre
{

private:
	int NumGames;
	Hours hours;
public:
	int getNumGames();
	void setNumGames (int nmGames);
	Hours& getHours();
	void setHours (Hours& hours);
	Game(int nmGames);

};
#endif
Topic archived. No new replies allowed.