Omer José Hernández Ramones
PreguntaTengo un error y no logro resolverlo, tengo el mismo codigo que el profesor
mi main se ve asi
#include <iostream> #include "Player.h" using namespace std; int main() { Player Hero(); Hero.CallImput(); return 0; }
hasta aqui todo bien, pero cuando lo compilo
me da este error
undefined reference to
Player::Player() undefined reference to
Entonces hago lo contrario del profesor y le agrego los parentesis al constructor y me genera solo este error
undefined reference to `Player::CallImput()
les comparto mi codigo a ver si es que tengo algo mal
main.cpp
#include <iostream> #include "Player.h" using namespace std; int main() { Player Hero(); Hero.CallImput(); return 0; }
Player.h
#ifndef PLAYER_H #define PLAYER_H class Player { public: Player(); void CallImput(); protected: private: }; #endif // PLAYER_H
Player.cpp
#include <iostream> #include "Player.h" using namespace std; Player::Player() { //ctor } void Player::CallImput() { cout <<"Aqui llamaria los inputs"<<endl; }
Le agradezco mucho a quien pueda ayudarme

Paul Anthony Llamoja Sarmiento
Diría que esto: Player Hero();, va sin paréntesis.
Player Hero;