Program crashes when executing funktion through subclass.

Hi first of i want to say thank you for readying my problem and trying to help, i love you.

I'm attending a programming class. And i have a projekt where i need to use class and sub class. The topic was sports. Here is the code:

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
using namespace std;


class team  //creating the class team
{
    public:
        string member;
    void setMember(string x){
        member = x;
    }

    string getMember(){
        return member;
    }
};

class Galeforce : public team{     //The subclass to the team Galeforce
    public:
    string getGaleforce(){         
    team tmg1;
    team tmg2;
    team tmg3;
    tmg1.setMember("Kaydop");
    tmg2.setMember("Voilentpanda");
    tmg3.setMember("Turbopulsa");
    cout<<tmg1.getMember()<<endl;
    cout<<tmg2.getMember()<<endl;
    cout<<tmg3.getMember()<<endl;
    }

};




int main()
{

    Galeforce gf;

    cout<<gf.getGaleforce()<<endl;


    return 0;
}


Now i get the three names then it stops working. If i do the exact same function it doesn't crash.

Thanks again for taking your time reading this.
The return type of Galeforce::getGaleforce() is std::string but it doesn't return anything.
Thanks Peter87. That worked! I changed it to a int which workes, but now i get numbers after the names:

Kaydop
Voilentpanda
Turbopulsa
6422044

Why? And how can i get rid of it?
You are printing the return value on line 43.
Thanks for all the help. How to do i make the code not print out the number? Sorry i don't have a teacher and i am not finding an answer online.
Topic archived. No new replies allowed.