structure does not name a type in c++
First, in C++ (but not C) every struct
or class
names a type. So if you declare a struct connection_header
, you also get a connection_header
type, so you can later declare connection_header var
some variable.
Then, typedef
both in C and C++ needs a type and a name. For example:
typedef long my_number_type;
declares my_number_type
as a synonym for long
So as others pointed out, drop the typedef
You are using typedef
without giving a name to the type. Just drop the typedef
, it is not needed here:
struct connection_header {
string url;
string method;
};
Next, connection_header
is declared inside of the Example
class, so you need to fully qualify its name in the implementation when it is a return type:
Example::connection_header Example::get_connection_header()
Try below code in cpp
file, add Example::
before connection_header
:
Example::connection_header Example::get_connection_header() {
return NULL;
}
connection_header
is defined inside Example
so you should give it its definition scope.
Also, the keyword typedef
will be ignored in C++. You can omit it