实例 C++ 函数声明和定义

x
 
#include <iostream>
using namespace std;
// Function declaration
void myFunction();
// The main method
int main() {
  myFunction();  // call the function
  return 0;
}
// Function definition
void myFunction() {
  cout << "I just got executed!";
}
                    

输出结果

I just got executed!