fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int foo(); //deklaracja
  5. int foo(); //deklaracja może się powtarzać
  6. int foo(); //i to wiele razy
  7.  
  8. int foo() //definicja, (może być tylko jedna), (definicja jest jednoczenie deklaracją)
  9. {
  10. return 42;
  11. }
  12.  
  13.  
  14. int foo() //nie można kilka razy zdefiniować jednej funkcji
  15. {
  16. return 123;
  17. }
  18.  
  19.  
  20. int foo(); //deklaracja może być po definicji
  21.  
  22. int main() {
  23. cout << foo() << endl;
  24. return 0;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int foo()':
prog.cpp:14:5: error: redefinition of 'int foo()'
 int foo() //nie można kilka razy zdefiniować jednej funkcji
     ^
prog.cpp:8:5: note: 'int foo()' previously defined here
 int foo() //definicja, (może być tylko jedna),  (definicja jest jednoczenie deklaracją)
     ^
stdout
Standard output is empty