Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Type your code here, or load an example. --->>> Godbolt.org // Compiler Explorer
- #include <iostream>
- int cppbasics() {
- // ---------------
- // What is a pointer / reference ...
- int a = 3;
- int& b = a;
- int* p = &a;
- long int q = (long int) &b;
- std::cout << a << " " << b << " " << p << " 0x" << std::hex << q;
- // ---------------
- // What is the arrow operator ...
- struct Test { int c;
- Test() {c=0;}; //constructor
- } b;
- Test* e = &b;
- int d;
- d = (&b)->c; std::cout << " d " << d;
- d = e->c; std::cout << " d " << d;
- d = (*e) .c; std::cout << " d " << d;
- // ---------------
- return 0;
- }
- int main() {
- cppbasics();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement