--- In [email protected], "Sharath A.V" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "Indika Bandara" <indikabandara19@>
> wrote:
> >
> > hi,
> > can somebody explain whether it is better to use a
> > reference/pointer/value in a following situation
> > 
> > class A
> > {
> > public:
> > int i_a;
> > };
> > 
> > class B
> > {
> > public:
> > int i_b;
> > };
> > 
> > class common
> > {
> > public:
> > common(const A *pa, const B *pa)
> > : i_a(pa->i_a),
> > i_b(pb->i_b)
> > {}
> > int &i_a;
> > int &i_b;
> > };
> > 
> > 
> > here what i want to do is use 'common' type of object as a container
> > to carry data which are in A and B
> > 
> > the questions i have are
> > 1) by using references does 'common' become large in size(sizeof
> > references is size of datatype)
> 
> No. Reference objects are only alias names for the existing objects,
> so they don't occupy any memory of its own.

Correction: actually reference type do occupy space, and it would be
equal to the size of pointer on the host machine. So it doesn't matter
with respect to memory whether you use pointers or references.

-
Sharath

Reply via email to