Click here to Skip to main content
16,009,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where do I write questions in C? Pin
jhwurmbach7-Sep-07 1:50
jhwurmbach7-Sep-07 1:50 
GeneralRe: Where do I write questions in C? Pin
gizmokaka7-Sep-07 2:26
gizmokaka7-Sep-07 2:26 
GeneralRe: Where do I write questions in C? [modified] Pin
jhwurmbach7-Sep-07 2:36
jhwurmbach7-Sep-07 2:36 
GeneralRe: Where do I write questions in C? Pin
gizmokaka7-Sep-07 2:57
gizmokaka7-Sep-07 2:57 
GeneralRe: Where do I write questions in C? Pin
jhwurmbach7-Sep-07 2:58
jhwurmbach7-Sep-07 2:58 
GeneralRe: Where do I write questions in C? Pin
gizmokaka7-Sep-07 6:23
gizmokaka7-Sep-07 6:23 
GeneralRe: Where do I write questions in C? Pin
jhwurmbach7-Sep-07 6:24
jhwurmbach7-Sep-07 6:24 
GeneralRe: Where do I write questions in C? Pin
El Corazon7-Sep-07 3:38
El Corazon7-Sep-07 3:38 
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)

GeneralRe: Where do I write questions in C? Pin
Russell'7-Sep-07 22:58
Russell'7-Sep-07 22:58 
QuestionIntelliSense and Sockets Pin
baerten6-Sep-07 21:52
baerten6-Sep-07 21:52 
AnswerRe: IntelliSense and Sockets Pin
Naveen6-Sep-07 23:20
Naveen6-Sep-07 23:20 
AnswerRe: IntelliSense and Sockets Pin
krmed7-Sep-07 0:48
krmed7-Sep-07 0:48 
QuestionProblem about draw text Pin
kcynic6-Sep-07 21:31
kcynic6-Sep-07 21:31 
AnswerRe: Problem about draw text Pin
KarstenK6-Sep-07 21:38
mveKarstenK6-Sep-07 21:38 
AnswerRe: Problem about draw text Pin
Nishad S6-Sep-07 21:54
Nishad S6-Sep-07 21:54 
AnswerRe: Problem about draw text Pin
Naveen6-Sep-07 22:26
Naveen6-Sep-07 22:26 
GeneralRe: Problem about draw text Pin
Nishad S6-Sep-07 22:30
Nishad S6-Sep-07 22:30 
GeneralRe: Problem about draw text Pin
Naveen6-Sep-07 22:34
Naveen6-Sep-07 22:34 
GeneralRe: Problem about draw text Pin
Nishad S7-Sep-07 0:52
Nishad S7-Sep-07 0:52 
GeneralRe: Problem about draw text Pin
Naveen7-Sep-07 0:56
Naveen7-Sep-07 0:56 
GeneralRe: Problem about draw text Pin
Nishad S7-Sep-07 1:29
Nishad S7-Sep-07 1:29 
GeneralRe: Problem about draw text Pin
kcynic7-Sep-07 1:16
kcynic7-Sep-07 1:16 
GeneralRe: Problem about draw text Pin
Nishad S7-Sep-07 1:26
Nishad S7-Sep-07 1:26 
GeneralRe: Problem about draw text Pin
kcynic7-Sep-07 3:55
kcynic7-Sep-07 3:55 
GeneralRe: Problem about draw text Pin
Nishad S8-Sep-07 0:47
Nishad S8-Sep-07 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.