C++ Function Parameter Pass structure reference to a function
#include <iostream> #include <string> using namespace std; struct Player /* ww w . ja v a 2s .c o m*/ { string m_name; }; void WelcomePlayer(Player& player) { cout << "Welcome to Text Adventure!" << endl << endl; cout << "What is your name?" << endl << endl; cin >> player.m_name; cout << endl << "Hello " << player.m_name << endl; } int main(int argc, char *argv []) { Player player; WelcomePlayer(player); return 0; }