Issue with C::B

So I've been reading and decided I would not only try to steer myself away from programming with Orwell Dev-C++, but Windows as well. I am trying to learn not only to compile from the terminal (which is going just fine), but I would like to know how to use C::B on Linux as well. So basically I have a bit of code that would compile just fine on Windows with Dev-C++, but does not compile on on C::B. It gives me the following compiler error:

error: expected primary-expression before ‘.’ token


I don't see any issue with the code, it's a simple class that only holds the variable "string name" so far and in a function called "introduction()" it asks the player to input a name into that string.

player.h
1
2
3
4
5
6
7
8
#include <string>

class player{

public:
    std::string name;

};


main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
#include "player.h"

using namespace std;

void introduction(){

    cout << "Hello, Adventurer!" << endl;
    cout << "What is your name?" << endl;
    cin >> player.name;

}

int main()
{
    return 0;
}
player is a class not an object. In order to access a non static member an object is required, like so:
1
2
    player p;
    cin >> p.name;
Haha holy shit I can't believe I did that. I feel like such an amateur ty lol.
closed account (3qX21hU5)
Also not sure if you only pasted a bit of the player.h file but be sure to include include guards on all header files.
Topic archived. No new replies allowed.