变量作用域
#include<iostream>
void print();
int main()
{
char a=0;
for(a=0;a<20;a++)
print();
return 0;
}
void print()
{
static int x=0;//静态变量声明,其值会一直保留
x++;
std::cout<<x<<std::endl;
}#include<iostream>
void print();
int main()
{
char a=0;
for(a=0;a<20;a++)
print();
return 0;
}
void print()
{
static int x=0;//静态变量声明,其值会一直保留
x++;
std::cout<<x<<std::endl;
}c++的目标之一是让使用类对象就像使用标准类型一样, 也就是说,常规的初始化语法不适用于类型Stock: int year=2001; struct thing { char *pn; int m; }; thing amabob={"w...
/*C风格字符串的声明和使用 #include<cstdio.h> int main() { char x[]={'H','e','l','l','o','&...
#include<iostream> using namespace std; struct books{ char name[10]; int num; float price; }book; int&nb...
#include<iostream> using namespace std; void addarr(int *k,int len); //文中形如sizeof(x)/sizeof(x[0]) 是用数组占用空...