//I have a structure type, designed to describe something
typedef struct _DESCRIPTION{
//imagine 10 members
} DESCRIPTION;
//I have a bunch of functions to manage structures of that
//type, and they take a reference to DESCRIPTION
void desc_do_something_1(DESCRIPTION& desc);
void desc_do_something_2(DESCRIPTION& desc);
void desc_do_something_3(DESCRIPTION& desc);
//Some where else in the programm I have a function which
//has a DESCRIPTION pointer, e.g. from a dynamic array of
//descriptions that uses the managing functions
void do_dialog_description(DESCRIPTION* pDesc)
{
//Inside I call
desc_do_something_1(*pDesc);
}
I have not considered this while constructing the functions. I use references because they work nice and the above sample code works fine. But I am worried...
What exactly is the difference between reference and pointer?
What is being passed/copied to desc_do_something_1 in the call? (I hope not all structure values)
typedef struct _DESCRIPTION{
//imagine 10 members
} DESCRIPTION;
//I have a bunch of functions to manage structures of that
//type, and they take a reference to DESCRIPTION
void desc_do_something_1(DESCRIPTION& desc);
void desc_do_something_2(DESCRIPTION& desc);
void desc_do_something_3(DESCRIPTION& desc);
//Some where else in the programm I have a function which
//has a DESCRIPTION pointer, e.g. from a dynamic array of
//descriptions that uses the managing functions
void do_dialog_description(DESCRIPTION* pDesc)
{
//Inside I call
desc_do_something_1(*pDesc);
}
I have not considered this while constructing the functions. I use references because they work nice and the above sample code works fine. But I am worried...
What exactly is the difference between reference and pointer?
What is being passed/copied to desc_do_something_1 in the call? (I hope not all structure values)