#include "pch.h"
#include <iostream>
#include <string>
using namespace std; //用于全局的命名 std
int func(int a)
{
static int c = 2; //此处c会随着函数的多次调用而变化,即多次使用这个函数时,c只在函数第一次被调用的时候被定义,
//往后的调用不会再次定义c,c变化后的值不会被清除,因为其被储存在全局数据区
c += a;
return c;
}
class student {
public:
int number;
char *name;
float score;
public:
void display(class student stu)
{
cout << "学号:" << stu.number << "\t";
cout << "姓名:" << stu.name << "\t";
cout << "分数:" << stu.score << endl;
}
};
int main()
{
class num {
public:
int a[100];
};
student std1;
std1.number = 31;
std1.name = "陈66";
std1.score = 99;
std1.display(std1);
int a = func(2);
int c = func(2);
cout<<a<<" "<<c<<endl;
//std1.display(std1);
//num num1;
/*for (int i = 1; i <= 100; i++) {
num1.a[i] = i;
cout << num1.a[i] << "\t";
}*/
/*int a = 1;
int b = func(a++);
cout << b << endl;
b = func(a++);
cout << b << endl;
int* p = &b; //指针
cout << *p << endl;
int &d = b; //引用,必须有对象
d++;
cout << d << endl;
cout << b << endl;
system("pause");*/
return 0;
}