--- In [email protected], "Indika Bandara" <[EMAIL PROTECTED]> 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. > 2)if so is it advantagous to use references over pointers A pointer would occupy memory to space to store the address of the object, but that is very insignificant amount of space. So, just use what suits you best. Sharath C and C++ FAQs: http://prokutfaq.byethost15.com
