Tag: incomplete-type
-
Can one forward declare a function taking a vector of incomplete type with a default value?
6 Below code snippet demonstrates some real issue I faced recently in my program: #include<vector> class A; void f( const std::vector<A> & = {} ); There is an incomplete class A, and a function declaration taking a vector of A‘s with empty default value. And the function is not even called anywhere. It works fine…
-
Why can a class that does not implement member functions be instantiated in C++?
14 For example: class B; class A { public: B f(); }; int main(int, char**) { A a; // no exception and error return 0; } The class A may be an incomplete type. Why can class A be instantiated in this example? I know that the program will fail to compile when the member…