|
gizmokaka wrote: 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:
gizmokaka wrote: rdb->customers->localData->colName
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.
Russell
|
|
|
|
|
Maybe I am missing something here but
the ADT is a module of it's own, and is separated from the application using it.
I can't put the struct in the user application, only the header and link to the
ADT object file.
and yes I do want to hide the structs to the user.
Again, how do you suggest I do that???
I think I didn't understand the last time
|
|
|
|
|
gizmokaka wrote: and yes I do want to hide the structs to the user.
You can not hide to the user what is part of the public interface the user is programming against.
But maybe a forward declaration can solve your problem? Just as to tell the compiler "There is a data-type named 'local_data', and you will know it when you need to".
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
You can notice that it's what I did in the header with a pointer to the table_rec struct
is that not enough?
should I also announce a pointer to data?
can you send me a piece of code on how to do it in my files??
source file:
typedef struct data
{
char** colName;
const struct element_interface** ifc;
Element* temp_row;
}data;
typedef struct table_rec
{
char TabInitFlag;
int iterator;
data* localData;
char** last_found_array;
Matrix tableArray;
int tableWidth;
int last_found;
}table_rec;
header:
typedef struct table_rec *Table;
please if you can resend the renovated code I would be more then thankful
and I will learn another new thing
thanks in advanced.
|
|
|
|
|
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.
If you do not want this, you will have to add access-functions for the data you need:
char* customer_get_colname( table_rec* customer); The implementation of this function has to be able to see the complete table_rec. But users of it have not.
-- modified at 8:42 Friday 7th September, 2007
Typo
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I think I understand my problem now thank you a lot.
I will try changing things and see how it works,
you really helped, thanks.
|
|
|
|
|
You're welcome.
And please, change the title of your first mail to include "[solved]"
Thank you!
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
|
View your post and use the 'modify' link in the lower right of it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: 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.
struct {
// some public code
char reserved[64];
// some public code
} data;
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
struct {
int key;
// some code
} packet1;
struct {
int key;
// some code
// some more code
} packet2;
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)
|
|
|
|
|
Simply let your code be something like this:
file.cpp
#include "file.h"
struct{
int tagA;
int tagB;
};
setTagA(..){..}
setTagB(..){..}
getTagA(..){..}
getTagB(..){..}
Operation1OnStruct(..){..}
Operation2OnStruct(..){..}
....
OperationNOnStruct(..){..}
PublicOperation1OnStruct(..){..}
PublicOperation2OnStruct(..){..}
PublicOperation3OnStruct(..){..}
file.h
setTagA(..);
setTagB(..);
getTagA(..);
getTagB(..);
PublicOperation1OnStruct(..);
PublicOperation2OnStruct(..);
PublicOperation3OnStruct(..);
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.
Russell
|
|
|
|
|
Hi,
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?
Big thanks
|
|
|
|
|
Try some third party applications like Visual Assist[^]. I cannot think of coding with out it now a days( Very useful ).
|
|
|
|
|
Quite often this can be solved by closing your project, then delete the .ncb, .aps, and .clw files (they will be recreated when required).
Re-open the project and the .ncb is rebuilt and your intellisense may work again.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I use CDC to draw a string in a control.
But it always draw extent to other controls,parent window,for example.
I only want to draw in its own client area.
How should I control to draw?
Thanks
GOOD LUCK
|
|
|
|
|
Use TextExtOut
Good luck!
Greetings from Germany
|
|
|
|
|
You can use DrawText. If not possible, apply a clip to the DC using SelectClipRgn.
- NS -
|
|
|
|
|
kcynic wrote: I use CDC to draw a string in a control.
Can you show me how you took the CDC ?
|
|
|
|
|
I think he got the problem of having CS_PARENTDC style.
- NS -
|
|
|
|
|
even if that style is present, if you take CClientDC or CWindowDC, it will apply the clilp so that the painting will not go outside that control.
Check the DCX_PARENTCLIP flag in the GetDCEx() function. CClientDC and CWindowDC calls this API with that flag.
|
|
|
|
|
The drawings should be in OnPaint. So the CPaintDC will be used. It is not having the clip.
Naveen.R wrote: Check the DCX_PARENTCLIP flag in the GetDCEx() function
It has NO use.
- NS -
|
|
|
|
|
NS17 wrote: The drawings should be in OnPaint
But he didn't mention so?
NS17 wrote: So the CPaintDC will be used. It is not having the clip.
And about the paint dc. I will all other parts that needn't to be updated in the current paint message. And offourse It will never allow you to draw on parent.
NS17 wrote: It has NO use.
Can u tell me why?
|
|
|
|
|
Naveen.R wrote: But he didn't mention so?
That I agree...
Naveen.R wrote: offourse It will never allow you to draw on parent.
Did you try it even once before?
Naveen.R wrote: Can u tell me why?
It is simply not working...
- NS -
|
|
|
|