X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8d864c2ab666871cf3391a12a8795c91f67f04f1..c600ed0e710d82601acf5ae4005b940f5cba8c08:/doc/sandbox.mdwn diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index 7a755ee02..5a2a10987 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -226,3 +226,25 @@ Testing. Test. 試験として書き込みします。 test I must **emphasise** this. + + +// more pointers + #include + using namespace std; + + int main () + { + int firstvalue = 5, secondvalue = 15; + int * p1, * p2; + + p1 = &firstvalue; // p1 = address of firstvalue + p2 = &secondvalue; // p2 = address of secondvalue + *p1 = 10; // value pointed to by p1 = 10 + *p2 = *p1; // value pointed to by p2 = value pointed to by p1 + p1 = p2; // p1 = p2 (value of pointer is copied) + *p1 = 20; // value pointed to by p1 = 20 + + cout << "firstvalue is " << firstvalue << '\n'; + cout << "secondvalue is " << secondvalue << '\n'; + return 0; + }