Click here to Skip to main content
15,912,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPrintPreview Pin
act_x12-Aug-04 8:49
act_x12-Aug-04 8:49 
GeneralSerial Communication and Picture Display in MFC Pin
JeremieJ12-Aug-04 8:36
JeremieJ12-Aug-04 8:36 
GeneralRe: Serial Communication and Picture Display in MFC Pin
mahade112-Aug-04 19:45
mahade112-Aug-04 19:45 
GeneralRe: Serial Communication and Picture Display in MFC Pin
JeremieJ12-Aug-04 21:56
JeremieJ12-Aug-04 21:56 
GeneralIGMP and Joining a Multicast Pin
byrd_cam12-Aug-04 8:35
byrd_cam12-Aug-04 8:35 
GeneralRe: IGMP and Joining a Multicast Pin
Ryan Binns12-Aug-04 21:04
Ryan Binns12-Aug-04 21:04 
GeneralPrintPreview Pin
act_x12-Aug-04 6:51
act_x12-Aug-04 6:51 
Generalhandling public and private structs Pin
elephantstar12-Aug-04 6:42
elephantstar12-Aug-04 6:42 
Hi there,

I know that it's bad coding practice to have public data members but what if you have a private struct containing about 10 fields. If I create a public struct containing the exact same fields and assign values you to them say from a form, can I pass that public struct as a parameter to the mutator method to set the private data members to? If the struct is public, I guess I don't need to pass it to the mutator. It can just be referenced within the method named for example Get_Data(). I included a snippet of code below:

public:
struct Data_1
{
int name;
int age;
//several other fields
};
Data_1 data1;

Get_Data();
Put_Data();

private:
typedef struct
{
int name;
int age;
//several other fields
}Data_2;

Data_2 data2;

void Get_Data()
{
data2.name = data1.name;
data2.age = data1.age;
}

void Put_Data()
{
data1.name = data2.name;
date1.age = data2.age;
}

Values of fields within the public structs are assigned to member variables in a form. Once set, the data in the private struct will then be written to a file. Am I doing this right or have I violated the coding convention?

Thanks!

GeneralProblem with enum Pin
BlackDice12-Aug-04 5:54
BlackDice12-Aug-04 5:54 
GeneralRe: Problem with enum Pin
David Crow12-Aug-04 6:07
David Crow12-Aug-04 6:07 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 6:14
BlackDice12-Aug-04 6:14 
GeneralRe: Problem with enum Pin
Navin12-Aug-04 6:34
Navin12-Aug-04 6:34 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 6:49
BlackDice12-Aug-04 6:49 
GeneralRe: Problem with enum Pin
David Crow12-Aug-04 6:36
David Crow12-Aug-04 6:36 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 6:42
BlackDice12-Aug-04 6:42 
GeneralRe: Problem with enum Pin
David Crow12-Aug-04 7:28
David Crow12-Aug-04 7:28 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 7:41
BlackDice12-Aug-04 7:41 
GeneralRe: Problem with enum Pin
David Crow12-Aug-04 8:19
David Crow12-Aug-04 8:19 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 9:01
BlackDice12-Aug-04 9:01 
GeneralRe: Problem with enum Pin
David Crow12-Aug-04 9:25
David Crow12-Aug-04 9:25 
GeneralRe: Problem with enum Pin
BlackDice12-Aug-04 6:56
BlackDice12-Aug-04 6:56 
GeneralRe: Problem with enum Pin
mahade112-Aug-04 20:14
mahade112-Aug-04 20:14 
GeneralRe: Problem with enum Pin
Gil Clark12-Aug-04 6:28
Gil Clark12-Aug-04 6:28 
GeneralRe: Problem with enum Pin
Tim Smith13-Aug-04 4:00
Tim Smith13-Aug-04 4:00 
GeneralRe: Problem with enum Pin
BlackDice13-Aug-04 4:35
BlackDice13-Aug-04 4:35 

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.