I must hide my implementation from the user(in this case me ),
Which implementation ? I just see a structure with data in it, no functions at all. How can somebody manipulate an 'object' without knowing what's inside.
How could you know that the structure contains a localData member if it is hidden ?
Hide implementation means that you put your function definitions in a cpp file and only 'show' (through a header file) the function prototypes.
true, and that's what I do,
only I am not allowed to reveal the members of the struct because
then the user of the ADT can change their type or value directly
which can hurt the functionality and integrity of the ADT.
The error message tells clearly what is the error:
at this line the structs are unknown.
You have to include the struct declarations before, so, as is telling Cedric, you canto put they in the header file.
Or, if you want to hide that structs to the user, you have to put ALL the code that use they in the SAME file, above the declaration of that structs.
Elseway the compiler can't know that table_rec and data exists.
The point remains: Your struct table_rec is part of a public interface (as you are reaching inside of it).
The public interface must be completely known to be used.
true, but not necessarily completely true. You can hide part of the implimentation, though it is more complicated and generally discouraged. Providing that the sizes are the same you can swap the contents, or remap them to a full structure. There are valid reasons to do this, and invalid ones. Hiding the interface isn't the best reason in the world. I will use it to handle state based multiple meanings.
// some public code
// some public code
This you can remap with another structure 64bytes in size without difficulty. The easiest way is with two structures, one in the header, your public one, and one in the source, a private one. The problem is this is difficult to maintain. I generally will keep it in the public interface using a union to hold multiple structures in the same space, but not all programmers will do that.
this is commonly done in communication programming
// some code
// some code
// some more code
If packet1 and 2 are different sizes you can tell them apart by size. But what if they were the same size, but had say short ints packed together vs. doubles. The key tells you which packet you have, you then recast the structure to the appropriate structure and you have access to the different packet information.
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
In this way the user can only use the public operations on the struct, but not the private ones because on the .h file you will put only declarations of public functions.
In file.cpp you have to define first the struct, then every function (public or private).
Important: the order!
First declare the struct and include the file.h, then define public and private functions.
the private functions on the cpp file can use each other ONLY if they calls function jet defined/declared. So the private Operation2OnStruct(..) can use Operation1OnStruct(..) but not OperationNOnStruct(..). Then if you want add some prototipes of the private function at the beginning of the file.
i include some headers to use sockets. The project works great, till now no problems.
Now, the IntelliSense will not work anymore.
My own classes and variables the IntelliSense shows the members and type, but
for example "accept(...);" it doesn't even know the function "accept" if i hit the F12 Key
Is there a special work to do, that IntelliSense works again?