问题:
解答:
#include <iostream>
using namespace std;
void print(const char* str)
{
	cout << str << endl;
}
void print(const char* str,int size)
{
	static int count = 0;
	count++;
	for (int i = 0; i < count; i++)
	{
		cout << str << endl;
	}
}
int main()
{
	
	print("Hello,World");
	cout << endl;
	print("Hello,World",1);
	cout << endl;
	print("Hello,World",10);
	cout << endl;
	print("Hello,World", 10);
	return 0;
}
 
运行结果:
 
考查点:
- static变量
 - 函数重载
注意: - static只初始化一次,即使再次调用到函数

 
2024年9月1日20:35:103




















