不知道为什么这个博客不能粘贴来自codeblocks的代码
假如存在对象:id,name,phone;可以分开来表达
int bx(int id, char name[ ] , char phone[ ])
但是这样表达存在缺点。所以我们用结构体
struct connect
{
int id;
char name[]
};
注意的是结尾要加上;且struct不在主函数内。
对结构变量成员赋值的话要用“.”,如果是字符串则用strcpy(person.name,“bob”)头文件为cstring。
# include <iostream>
using namespace std ;
struct weather
{ double temp; double wind; } yesterday ;
int main ( )
{ weather today ;
yesterday . temp = 10.5 ;
yesterday . wind = 3.1 ;
today = yesterday ; // 结构变量整体赋值
cout << “Temp = ” << today . temp << endl ;
cout << “Wind = ” << today . wind << endl ;
}