Are you familiar with classes? The tutorial on this site has a good chapter on them:
http://cplusplus.com/doc/tutorial/classes/
That chapter covers the basics. When you understand them, you can move on to the more detailed topics in the tutorial under the "Object Oriented Programming" heading:
http://cplusplus.com/doc/tutorial/
Classes are the basis of object oriented programming. They encapsulate groups of data and the functions that operate on that data. In your RPG, for instance, there might be a class called Player that contains data such as health, level, weapon, stat points, etc. All of the functionality associated with the Player would be contained within the class. For instance, there might be a battle() function that looks at the Player's weapon for input, and based on results could modify the Player's health and stat points. Or something like that.
(Note: This is just an example. I don't write RPGs, so I really haven't thought through whether this would be a good design approach. Others on this site do and would be better help with design questions.)
Potential classes in your design could be:
Room (different locations in your game)
Map (A graph of Rooms and how to get from one to another)
Weapon
Enemy
Treasure
Knapsack (knows how much treasure or other items can be carried)
etc.
You can write and test each class in isolation before integrating all of them into your final project.
And when you write a class, generally you put your class definition into a .h header file, and all of the member functions into a .cpp source file.
MyClass.h:
1 2 3 4 5 6 7 8
|
class MyClass
{
public:
MyClass(int value);
void increment();
private:
int a;
};
|
MyClass.cpp
1 2 3 4 5 6 7 8 9
|
#include "MyClass.h"
MyClass::MyClass(int value) : a(value)
{ }
void MyClass::increment()
{
a++;
}
|