Reputation: 483
I'm new to C++ and while I'm reviewing someone else's code, I ran into an expression I don't understand.
In the header file I have a normal class definition:
//in data.hpp
class DATA_C : public QThread
{
Q_OBJECT
// the rest of class definition...
}
A snippet of the source file:
//in data.cpp
class DATA_C data_container;
I can understand "DATA_C data", which is a declaration; but what is "class DATA_C data_container"? What does it do?
Thanks in advance.
Upvotes: 2
Views: 62
Reputation: 141554
In this context tt has exactly the same meaning as DATA_C data_container;
. In many contexts you can optionally use the term class X
, if it would have been valid to just use X
.
In general you can use class X
when X
has not been defined yet and it declares the class (but doesn't define it). But class DATA_C data_container;
would not be allowed if DATA_C
had not been previously defined, because you cannot instantiate an object of incomplete type.
Upvotes: 1