If I have a header like this:
#include <vector>
class Data;
class A {
// const Data& getData( int i ) const { return a[i]; }
std::vector<Data> a;
};
the compiler compiles it normally, because it doesn't need to know a bit about Data type.
Retuning a value by reference does not depend on a class implementation and therefore do not require any knowledge of the class internals.
But when I uncomment the accessor compiler starts to complain on invalid use of incomplete type 'class Data'
. Why?