Thread: Help!

  1. #1
    Registered User
    Join Date
    Mar 2002


    Ok,...I've been trying to figure this out for the past hour..

    tree<T>::tree(int nr, int nc, int nl, const T& value)

    so this constructor takes an int, int, int , and what?

    I've tried everything, please help...

    I don't understand the "&"!?... i thought "& value" would give the address of value???

    and let say I've declared T as an integer with the line..
    tree<int> mytree(1,2,2,y); //What is y!??
    Last edited by Jez_Master; 04-18-2002 at 07:39 AM.
    Which is the master, which is the student?

  2. #2
    If you are using ints that constructor takes 4 int arguments, the last is a constant and is passed by reference (&). ALL this means that instead of passing a copy of value it is passing the address of value. The reason is that T could be anything and anything could be very large, so passing a reference to the actual object saves a call to a copy constructor and saves on the extra memory that the new object would take up. Got it?

Popular pages Recent additions subscribe to a feed