fork(1) download
  1. #include <iostream>
  2.  
  3. struct TestStructure;
  4.  
  5. void TestFunction(TestStructure*); // forward declaration
  6.  
  7. struct TestStructure {
  8. int i;
  9. void TestFunction(TestStructure* /*unused*/) {
  10. std::cout << "TestStructure TestFunction\n";
  11. }
  12. void foo() {
  13. std::cout << "From foo:\n";
  14. TestFunction(this);
  15. std::cout << "::TestFunction:\n";
  16. ::TestFunction(this);
  17. }
  18. };
  19.  
  20. void TestFunction(TestStructure* /*unused*/) {
  21. std::cout << "Free TestFunction\n";
  22. }
  23.  
  24. int main() {
  25. std::cout << "From main:\n";
  26. TestFunction(nullptr);
  27.  
  28. TestStructure t;
  29. t.foo();
  30. }
  31.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
From main:
Free TestFunction
From foo:
TestStructure TestFunction
::TestFunction:
Free TestFunction