Can I use forward declaration for template class?
I try:
template<class que_type>
class que;
int main(){
que<int> mydeque;
return 0;
}
template<class que_type>
class que {};
I get:
error: aggregate 'que<int> mydeque' has incomplete type and cannot be defined.
This is not a template issue. You cannot use a type as a by-value variable unless it has been fully defined.
No. At the point of instantiation, the complete definition of the class template must be seen by the compiler. And its true for non-template class as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With