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.
#include <iostream>
#include "Genre.h"
#include "Game.h"
#include "Hours.h"
usingnamespace 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;
}
#ifndef GENRE_H
#define GENRE_H
#include <string>
usingnamespace 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