Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

pointers?...a few questions

  • 25-08-2009 02:22AM
    #1
    Registered Users, Registered Users 2 Posts: 50 ✭✭


    Q1:Does a pointer allow you to defeat scope?

    Q2:Do you need a pointer to assign to a "new" on the heap
    int *Array;
    Array=new double[]
    

    Q3:Can i assign array(the pointer) in any function in the class implementation?

    Q4:You know for a copy constructor its always a refrence type as a parameter
    class example;
    ...
     
    example :: example(const example&)
    

    its something like this now if this could be explained to me i really do think i could logically get alot of other things aswell as just copy constructors
    why is it a refrence why can it not be just of type "example"?? so walk me through it as i give my parameter object of class example say example1 and i pass this object as a parameter does this become the refrence or what or is this refrenced to?and what is the purposeof it how is it useful to have it as a refrence when do you know to make it a refrence?


    if you can answer these questions especially the last 1 its really appreaciated!!!


Comments

  • Registered Users, Registered Users 2 Posts: 3,945 ✭✭✭Anima


    Q4:You know for a copy constructor its always a refrence type as a parameter

    Code:
    class example;
    ...

    example :: example(const example&)
    its something like this now if this could be explained to me i really do think i could logically get alot of other things aswell as just copy constructors
    why is it a refrence why can it not be just of type "example"?? so walk me through it as i give my parameter object of class example say example1 and i pass this object as a parameter does this become the refrence or what or is this refrenced to?and what is the purposeof it how is it useful to have it as a refrence when do you know to make it a refrence?

    You should read up on passing by reference and passing by value.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey




Advertisement