[ create a new paste ] login | about

Link: http://codepad.org/7Cs0AthX    [ raw code | output | fork ]

C++, pasted on Dec 2:
#include <iostream>

using namespace std;

struct A
{
    int x;
};

void foo(const A &a)
{
    int * p = (int *)&a;
    *p = 8;
}

int main(int argc, char** args)
{
    A a;
    a.x = 3;
    foo(a);
    cout << a.x << endl;
}


Output:
1
8


Create a new paste based on this one


Comments: