#include <iostream>
using namespace std;
struct teacher
{
int id;
char name[64];
};
//c++对全局变量的检测能力加强, 一个变量不管是声明,还是定义,只能出现一次
int g_val ; //全局变量
//int g_val = 10;// 又一个全局变量;c语言可以重复定义;C只能出现一次
//1实用性的增强, C语言必须先定义;c++对于变量的定义的位置,可以随意,没有要求
int test1(void)
{
int i = 0;
for (i = 0; i < 10; i++)//这个i和for循环周期一样
{
}
for (int i = 0; i < 10; i++) {
}
return 0;
}
/* c把teacher看做一个复杂类型的名称,故应用时必须将struct关键字写出来
void test2()
{
struct teacher t1;
}
*/
void test2()//C++中 在使用struct 时候不需要再将 struct 写进来,c++把teacher当类
{
teacher t1;
}
/*
void f(int i)
{
cout << "i = " << i << endl;
}
int main(void)
{
f(1,2,3)//c可以多个参数;c++只可以一个参数,对参数严格
}
*/
int g(int a,int b,int c)
{
return 100;
}
//函数一定要有返回值,如果函数没有返回值,也要加word
int main(void)
{
g(1,2,3);
return 0;//c++对函数形参传递 返回值做了严格检查
}