首页 > 其他分享 >OC之【typedef的使用】

OC之【typedef的使用】

时间:2022-12-09 15:06:24浏览次数:36  
标签:typedef Point int OC char 使用 Integer String1

// #define Integer int
// 给基本数据类型起别名
void
typedef int

typedef Integer

typedef unsigned int UInteger;

int a = 10;

Integer b = 9;

UInteger c = 11;

MyInteger d = 89;
}

// 给指针类型起别名
void
char *s = "hello";

typedef char

String s1 = "hello";
}

void


typedef struct {
float
float
} Point;

Point p = {10, 10};
}

void
typedef struct {
float
float
} Point;

typedef Point

// typedef struct Point {
// float x;
// float y;
// } * PP;

Point point = {10.0f, 20.0f};

PP

printf("x=%f, y=%f\n", pp->x, pp->y);
}

void
typedef enum {
spring,
summer,
autumn,
winter
} Season;

Season s = spring;
}

int sum(int a, int
int
printf("%d+%d=%d\n", a, b, c);
return
}

// 给指向函数的指针定义一个别名SumPoint
void
typedef int (*SumPoint)(int, int);

SumPoint p = sum;

4, 5);
}

void
typedef char
#define String2 char *

String1
// String1 s1;
// String1 s2;

String2
// char *s3, s4;
// char *s3;
// char s4;
}

int main(int argc, const char
{

int

// int a;
// int b;

return 0;
}

标签:typedef,Point,int,OC,char,使用,Integer,String1
From: https://blog.51cto.com/u_15907570/5925302

相关文章

  • OC之【NSMutableString的使用】
    可变字符串的创建void//预先分配10个字数的存储空间NSMutableString*str=[[NSMutableStringalloc]initWithCapacity:10];//设置字符串内容setString:@......
  • OC之【NSArray使用】
    #import<Foundation/Foundation.h>#import"Student.h"创建一个数组void//创建一个空的数组NSArray*array=[NSArrayarray];//创建有1个元素的数组NSAr......
  • OC之【NSMutableArray的使用】
    #import<Foundation/Foundation.h>#import"Student.h"voidNSMutableArray*array=[NSMutableArrayarrayWithObject:@"1"];//添加元素addObject:@"2"];addObj......
  • OC之【@protocol协议】
    #import<Foundation/Foundation.h>@protocolStudy<NSObject>默认就是@required-(void)test3;表示必须实现的方法//虽然字面上说是必须实现,但是编译器并不强求某个类......
  • OC之【@class】
    如果是继承某个类,就要导入类的头文件@classbook.h文件:#import<Foundation/Foundation.h>Book:NSObjectintprice;@end文件:"Book.h"Book-(void)dealloc{NSL......
  • OC之【深拷贝(mutableCopy)和浅拷贝(copy)】
    文件#import<Foundation/Foundation.h>#import"Student.h"#import"GoodStudent.h"//copy语法的目的:改变副本的时候,不会影响到源对象字符串的拷贝(深拷贝)//深拷贝:内容......
  • OC之【NSNumber的使用】
    #import<Foundation/Foundation.h>void//将int类型的10包装成一个NSNumber对象NSNumber*number=[NSNumbernumberWithInt:10];NSLog(@"number=%@",number);......
  • OC之【NSDictionary详解】
    main.m文件#import<Foundation/Foundation.h>#import"Student.h"字典的初始化void//NSDictionary是不可变的NSDictionary*dict=[NSDictionarydictionaryWit......
  • OC之【c语言结构体】
    <stdio.h>void//这个机构只能在函数内部使用//定义一个名为Student的结构体类型structintage;//年龄char*name;//姓名floatheight;//身高};......
  • OC之【NSMutableDictionary的使用】
    main.m文件#import<Foundation/Foundation.h>#import"Student.h"可变字典的使用void//创建一个空的字典NSMutableDictionary*dict=[NSMutableDictionarydicti......