oc结构

结构 在oc中只能声明变量 不能声明函数和类

结构声明

struct DateT {

int month;

int day;

int year;

};

结构可以在起最后的分号之后定义结构变量,并且可以格式化
 

struct DateT {

int month;

int day;

int year;

}today{1,2,3};

结构可以不定义名字 ,但是要先声明变量

struct {

int month;

int day;

int year;

}today{1,2,3};

结构可以嵌套
 

struct DateT {

int month;

int day;

int year;

};

struct Time {

int hours

int seconds;

int min;

};

struct DateTime {

struct DateT date;

struct Time time;

}today{1,2,3};

 调用和平常调用一样  就是多了一个嵌套
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/flyingdreaming/p/struct.html