I am trying to make a player using a Class as a setup. These are my files:
Player.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#pragma once
#include <iostream>
#include <string>
usingnamespace std;
class Player
{
public:
Player();
void initPlayer(string name, int level, int maxExp);
void displayPlayer();
private:
string _name;
int _level;
int _exp;
int _maxExp;
};
The Player object passed to initPlayer is passed by value, meaning the function receives a copy of the Player object fed to it and any changes made to that copy are not reflected in the original.