#include <iostream>
class Player
{
private :
int health;
int mana;
int attack;
int defense;
int speed;
public :
Player( )
{
health = 0 ;
mana = 0 ;
attack = 0 ;
defense = 0 ;
speed = 0 ;
}
void attack( )
{
std:: cout << "You attack!\n " ;
}
void defend( )
{
std:: cout << "You defend!\n " ;
}
} ;
int main( )
{
Player player1;
player1.attack ( ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgUGxheWVyCnsKICAgIHByaXZhdGU6CiAgICAgICAgaW50IGhlYWx0aDsKICAgICAgICBpbnQgbWFuYTsKICAgICAgICBpbnQgYXR0YWNrOwogICAgICAgIGludCBkZWZlbnNlOwogICAgICAgIGludCBzcGVlZDsKCiAgICBwdWJsaWM6CiAgICAgICAgUGxheWVyKCkKICAgICAgICB7CiAgICAgICAgICAgIGhlYWx0aCA9IDA7CiAgICAgICAgICAgIG1hbmEgPSAwOwogICAgICAgICAgICBhdHRhY2sgPSAwOwogICAgICAgICAgICBkZWZlbnNlID0gMDsKICAgICAgICAgICAgc3BlZWQgPSAwOwogICAgICAgIH0KCiAgICAgICAgdm9pZCBhdHRhY2soKQogICAgICAgIHsKICAgICAgICAgICAgc3RkOjpjb3V0IDw8ICJZb3UgYXR0YWNrIVxuIjsKICAgICAgICB9CgogICAgICAgIHZvaWQgZGVmZW5kKCkKICAgICAgICB7CiAgICAgICAgICAgIHN0ZDo6Y291dCA8PCAiWW91IGRlZmVuZCFcbiI7CiAgICAgICAgfQp9OwoKaW50IG1haW4oKQp7CiAgICBQbGF5ZXIgcGxheWVyMTsKICAgIHBsYXllcjEuYXR0YWNrKCk7Cn0=
compilation info
prog.cpp:25:9: error: 'void Player::attack()' conflicts with a previous declaration
}
^
prog.cpp:8:13: note: previous declaration 'int Player::attack'
int attack;
^
prog.cpp: In constructor 'Player::Player()':
prog.cpp:17:20: error: invalid use of member function (did you forget the '()' ?)
attack = 0;
^
stdout