jeudi 5 mars 2020

Visual Studio 2017 "use of undefined type"

I have the following code which fails to compile with Visual Studio 2017 with error

Error C2027 use of undefined type 'A'

but is compiling fine in Visual Studio 2012 & Visual Studio 2015.

#include <iostream>

    class A;
    std::string s = typeid(A).name();

    class A
    {
        public:
           int a;
    };

    int main()
    {
        std::cout << "Hello World!\n"; 
    }

Can anyone suggest what exactly is the problem with VS 2017 compilation and how to fix this?

Aucun commentaire:

Enregistrer un commentaire