C++ examples for Function:Function Parameter
Pass structure reference to a function
#include <iostream> #include <string> using namespace std; struct Player // www . j ava2s.c om { 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; }