Help!

This is a discussion on Help! within the C++ Programming forums, part of the General Programming Boards category; 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) ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    51

    Help!

    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 08:39 AM.
    Which is the master, which is the student?

  2. #2
    Unregistered
    Guest
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21