pass by pointer is not working

Posted by user323422 on Stack Overflow See other posts from Stack Overflow or by user323422
Published on 2010-06-18T05:12:33Z Indexed on 2010/06/18 5:23 UTC
Read the original article Hit count: 228

Filed under:
#include"iostream"
class CMessage
{
public:int a;
       CMessage(){}
       ~CMessage(){}
};
void Testing(CMessage *f_pMessage)//l_pMessage is output parameter
{
    f_pMessage = new CMessage();
    f_pMessage->a = 1;
}
int main()
{
    CMessage *l_pMessage =NULL;
    Testing(l_pMessage);
    std::cout<<l_pMessage->a;//getting l_pMessage = NULL;
    return 0;
}

when i called testing then inside testing f_pMessage is getting intialize but as ssoon as i after excuting testing function it should be store in l_Pmessage but it is showing NULL.confussed.....

© Stack Overflow or respective owner

Related posts about c++