-4

I am having issues with my game. I haven't made much of a game so far, but I am trying to call a string using a external function from my bin class. When I compile, It says I can't have non-static variables.

#include <iostream>
#include <stdlib.h>

using namespace std;

class Bin {
    string gameStart = "How would you like to start?\n";
};

Bin bin1;

int main () {
    cout << bin1.gameStart;
}

Just for reference, I have tried looking for solutions, but to no prevail.

Update: Hi again. I have read some of the feedback from my question. I see that Raw N and Angew have made some valid points. I would like to ask if these two nice people: Where does the header go. How can i get that version of the compiler?

Thanks!

Update: I managed to find out how to compile my code in c++14. There is a console command that can be used for this. I updated my open.bat file, which i use to compile my notepad code. Everything is working fine now. Thanks all!

Q.Reilly
  • 23
  • 5

1 Answers1

4

The default for a class' members is private, so without specifying differently, your data will not be accessible from outside the class.
Add public: inside the class, before the declarations.

Aganju
  • 6,295
  • 1
  • 12
  • 23