Simple text based game im working on, tell me whats wrong please, it keeps crashing.

If you press 1 when it asks you to choose one, then it will say test and crash immediately. What did I do wrong.
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
#include <iostream>
#include <string>

using namespace std;


class storyline1{
public:

string oldman1(){

cout << " test ";
};
};

int main()
{
    cout << " Welcome to Tyler Tongen's first text based game, the decisions you make \n in this game will determine if you survive or not \n \n Goodluck \n." << endl;
    cout << " You Wake up on the side of a dusty road \n \n An Old man with a hood and a quiver full of arrows walks up to you \n \n Wake up! There is no time to explain, but you need to come with me!";
    cout << " \n 1. Go with the man. \n 2. Run away." << endl;
    storyline1 to1;
    int x;
    cin >> x;
        if( x == 1 ){
            to1.oldman1();
        }
        return 0;
};

Thanks in advance <3
change the
oldman1()
to void. Note that using other types(other than void) should return values. Say you want it to be string, you just add return " "; which in this case would return it with a value of a single space. Hope this helps. :)
Topic archived. No new replies allowed.