本文写在初学c++的第一天,从入门开始
1,无参无反
#include<iostream>
using namespace std;
void test01(){
cout << "this is test01 " << endl;
}
int main(){
test01();
system("pause");
return 0;
}
2,有参无反
#include<iostream>
using namespace std;
void test02(int a){
cout << "this is test02 a = " << a << endl;
}
int main(){
test02(41);
system("pause");
return 0;
}
3,无参有反
#include<iostream>
using namespace std;
void test03(){
cout << "this is test03" << endl;
return 1000;
}
int main(){
int num1 = test03();
cout << "num1 = " << num1 << endl;
system("pause");
return 0;
}
4,有参有反
#include<iostream>
using namespace std;
void test04(int a){
cout << "this is test04 a = " << a << endl;
return a;
}
int main(){
int num2 = test04(10000);
cout << "num2 = " << num2 << endl;
system("pause");
return 0;
}