Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

pointers?...a few questions

Options
  • 25-08-2009 2:22am
    #1
    Registered Users 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 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 Posts: 9,579 ✭✭✭Webmonkey




Advertisement