My Source Code:
#include <iostream>
#include <string>
int main(void) {
struct character{
std::string name;
unsigned short int age;
unsigned short int height;
unsigned short int weight;
};
std::cout << "==============================================\n";
std::cout << "Welcome to Jake's Character Console! (JCC v1.0)\n";
std::cout << "==============================================\n\n";
std::cout << "Let's start by describing your character..." << std::endl << std::endl;
std::cout << "What is your character's name? ";
std::cin >> character.name; \\ <======= ERROR HERE ========
std::cout << "Let's start by describing your character..." << std::endl << std::endl;
std::cout << "Let's start by describing your character..." << std::endl << std::endl;
std::cin.get();
std::cin.get();
return 0;
}
The Problem:
The error occurs at the 'std::cin >> character.name;' statement. I am a complete, absolute novice at C++. I was making this program to learn the ropes of data structures, but I ran across this error. How could I simply rewrite this code so that I could input data into the character.name member? Also, any expert advice would be much appreciated; I don't have much C++ prior knowledge. Thank you SOF community.
The Error:
'A non-static member reference must be relative to a specified object.'