Struct or Class notation with pointer inside Struct?

Hi!

I looked through code of a large project and I saw this:

1
2
3
4
5
6
7
8
struct SNVData
{
INT NumberOfCells;
class CNVConn* Connector;
...
struct SNVPoint* Location;
...
};


I've never seen such a notation.
Is this a special keyword or just a hint for a programmer?
In C you have to write struct before the type name in some situations. In C++ you don't have to do that.
So in C++ is only hint, Thanks
This is named elaborated type specifier
For example a function can have the same name as a class. So to distiguish the function and the class usually elaborated type specifier is used with classes. Also elaborated type specifier introduce a new class name when the class is not defined yet..

In your example it seems that class CNVConn and struct SNVPoint were not defined yet in this compilation unit and maybe the definition even are not required. So elaborated type specifiers introduce two names CNVConn and SNVPoint in the scope. Without class key the compiler would issue an error.
For example:

class CNVConn

is not implemented anywhere

without keyword class

 
CNVConn* Connector;


Compiler give me an error
You are right. If the class was not defined prior elaborated type specifier introduces a new name in the scope.
I search in all files of project and found nothing.

In that case.
whether the structure can be defined in a structure such as in DLL? because this:

1
2
3
4
5
6
7
8
struct SNVData
{
INT NumberOfCells;
class CNVConn* Connector;
...
struct SNVPoint* Location;
...
};


is in header file
Topic archived. No new replies allowed.