- 博客(7)
- 收藏
- 关注
转载 [Obj-C笔记] "self = [super init]"的解释与潜藏bug
[Obj-C笔记] “self = [super init]”的解释与潜藏bug Objective-C的推荐init方法写法如下:- (id) init{ if(self = [super init]) { //为子类增加属性进行初始化 } return self;}这里涉及了几个问题,1.[super init]的作用:面向对象的体现,先利用
2015-06-12 15:50:10
278
转载 java中向上转型(upcast)和向下转型(downcast)
先看下面的程序:class Useful { int value = 20; public void f() {System.out.println(“f() in the Useful class”);} public void g() {System.out.println(“g() in the Useful class”);} } class MoreUseful extend
2015-05-21 18:27:55
522
转载 swift之mutating关键字【转】
在swift中,包含三种类型(type): structure,enumeration,class 其中structure和enumeration是值类型(value type),class是引用类型(reference type) 但是与objective-c不同的是,structure和enumeration也可以拥有方法(method),其中方法可以为实例方法(instance metho
2015-05-15 15:25:22
301
原创 [Leetcode]Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?给定一个链表,不使用额外空间,判断它是否有环;给出链表结构
2015-04-30 13:14:56
260
原创 剑指Offer 面试题3:二维数组中查找
剑指Offer 面试题3:二维数组中查找 题目:在一个二维数组中,每一行都是按照从左到右递增的顺序排列,每一列都按照从上到下递增的顺序排序,请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。例如下面的数组 1 2 8 9 2 4 9 12 4 7 10 13 6
2015-04-28 17:34:51
317
原创 不使用sizeof获取机器int型的字节数
不通过sizeof如何获得int 的字节数呢?可以利用 左移运算符 这里解释一下左移:就是在二进制的基础上对数字进行平移。左移一次,低位补零,高位舍弃。 比如二进制数 00000001(也就是十进制的1),左移一次变成了00000010(也就是十进制的2) ,同时也就是说,每左移一次,数的值相当于乘以2,当然也就极限。00000001左移8次之后,就变成了00000000。同时还有右移
2015-04-27 17:37:30
345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人