<<<Index>>>

Rreference Trapdoor


  • Returning a reference to a member is a trapdoor:

  • Trapdoor is a secret way of gaining access to a program, online service, or other resource. Trapdoors are built into the software by the original programmers as a way of gaining special access to particular software functions.


// point.h
class Point
{
public:
    int& refx();
private:
    int m_x;
    int m_y;
};

// point.cpp
#include "point.h"
int& Point::refx()
{
    return m_x;
}

// main.cpp
#include "point.h"
void main()
{
    Point pt;
    pt.refx() = 14;
}
<<<Index>>>