Skip to main content
C++ standard does not require "return 0;" at the end of main. This is unnecessary. So I removed it.
Source Link
user405725
user405725

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo();  return 0; } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo();  return 0; } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo(); } 

This outputs:

Hi 
added 19 characters in body
Source Link
gr0v3r
  • 778
  • 5
  • 5

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo();  return 0; } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo(); } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo();  return 0; } 

This outputs:

Hi 
enhanced code a little bit, to avoid using uninitialized pointer and remove unnecessary `;`
Source Link
user405725
user405725

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;}; }; struct B { A*A ptr;a; A* operator->() { return ptr;&a; } }; int main() {   B b; b->foo(); } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;}; }; struct B { A* ptr; A* operator->() { return ptr; } }; int main() {   B b; b->foo(); } 

This outputs:

Hi 

The operator -> is used to overload member access. A small example:

#include <iostream> struct A { void foo() {std::cout << "Hi" << std::endl;} }; struct B { A a; A* operator->() { return &a; } }; int main() { B b; b->foo(); } 

This outputs:

Hi 
Source Link
gr0v3r
  • 778
  • 5
  • 5
Loading