Why is this object not created? C ++

Here is my main one. All I'm trying to do is create a class file object, this is probably a very Nubian question, so sorry, you just need to know what I'm doing wrong.

#include <iostream> #include "Player.h" using std::cout; using std::cin; int main() { cout << "Hello and welcome to the student adventures game.\n"; Player player1(); } 
+6
source share
2 answers

You have declared a function that returns a Player type; see the most unpleasant parsing

To determine the object, try updating

 Player player1(); 

to

 Player player1; 
+12
source

You should not use brackets when declaring an object without parameters, otherwise the compiler will consider that you declare a function that returns Player and which does not accept any parameters.

+4
source

Source: https://habr.com/ru/post/948887/


All Articles