Wednesday, February 23, 2011

References and pointers and const

Gahh!!! Mid-terms tomorrow. Everyone's panicking about const-ness and references! 
Thought I'd write some nonsense for practice.

oh boy so nervous. XD

// chinykian
// 23 Feb 2011

#include
iostream

const int gInt1 = 10;
const int gInt2 = 20;

const int*const& MyFunc (const int*& pI)
{
    pI = &gInt2;
   
    return pI;
}

const int*const& (*pFP) (const int*& pI) = MyFunc;

int main(void)
{
    const int*const& (**const&ppFP) (const int*& pI) = &pFP;
   
    const int* pI = &gInt1;
    std::cout << *((*ppFP)(pI)) << std::endl;
   
    return 0;
}