#include <memory>
class Data;
std::unique_ptr<Data> p;
//class Data{}; // not working without this
int main(){}
Compilation of this code with g++-5 gives such error:
invalid application of ‘sizeof’ to incomplete type ‘Data’
Can somebody explain why if I uncomment 4th line compilation will be successful? As I understand in 3rd line compiler hasn't full information about type Data. We have only forward declaration in this line. Real declaration occures in 4th line.