get_pointer 成员函数小结

来源:互联网 发布:microsoft网络客户端 编辑:程序博客网 时间:2024/06/15 04:19
#include "iostream"class TestA{public:TestA(int a){        m_pA = new int(a);};~TestA(){delete m_pA;m_pA = NULL;};public:int*m_pA;int* getA(){return m_pA;};int** getAA(){return &m_pA;};void print(){std::cout << " testA : " << * m_pA << std::endl;}};int main(int argc, char *argv[]){TestA* pTestA = new TestA(2);int* pInt = pTestA->getA();pTestA->print();int* p = new int(3);pInt = p;int** pIntTwo = pTestA->getAA();//*pIntTwo = p;std::cout << " out out : " << *pInt << std::endl;std::cout << " out : " << *pInt << std::endl;pTestA->print();    return 0;}


 

原创粉丝点击