doubt on scope of pointers VERY URGENT!!!!!!!!! PLEASE HELP ME.........

Discussion in 'C++' started by edu.mvk, Jul 10, 2006.

  1. edu.mvk

    edu.mvk Guest

    Hi ,

    if the program is like this ...

    please tell me the scope of the "ptr" and the vector "vec_ptr"...

    class A
    {
    private :
    vector< B* > vec_ptf ;
    public :
    init();
    shutdown();
    }

    A :: init()
    {
    B *ptr;
    int i=0;
    while( i < 10 )
    {
    ptr = new B();
    vec_ptr.push_back( ptr );
    }
    }

    A :: shutdown()
    {
    if ( !vec_ptr.empty() )
    {
    vector<B*>::iterator B_Iterator;
    for( B_Iterator = vec_ptr.begin(); B_Iterator !=
    vec_ptr.end(); B_Iterator++ )
    {
    delete( vec_ptr[QCop_Iterator] );
    }
    }
    }

    if i have declared and instantiated the " ptr " in the function init()
    like above and after pushing that into the vector of type B* will the
    object be remain even in the shutdown() function....??

    please tell me the scope of that pointer ptr and the vector that
    containing the ptr.


    Tthanks
     
    edu.mvk, Jul 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    389
    Milsnips
    Nov 15, 2006
  2. edu.mvk
    Replies:
    2
    Views:
    335
    Forest
    Jul 10, 2006
  3. edu.mvk
    Replies:
    0
    Views:
    298
    edu.mvk
    Jul 10, 2006
  4. olivier.melcher

    Help running a very very very simple code

    olivier.melcher, May 12, 2008, in forum: Java
    Replies:
    8
    Views:
    2,356
  5. Saranya

    Plz help its very urgent doubt in uploading a webform

    Saranya, Aug 19, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    111
    Sarat Pediredla
    Aug 20, 2006
Loading...

Share This Page