从编程语言直观了解面向对象各种面向对象编程语言相互有别,但都能看到它们对面向对象三大机制的支持,即:
“封装、继承、多态”封装,隐藏内部实现继承,复用现有代码多态,改写对象行为使用面向对象编程语言(如C#),可以推动程序员以面向对象的思维来思考软件设计结构,从而强化面向对象的编程范式。C#是一门支持...
分类:
其他好文 时间:
2014-05-19 20:06:01
阅读次数:
186
这几天面试的时候,反复被问到一个关于Service的问题。之前做了一个APP。有一个应用场景是,需要开机启动一个Service,在Service中另开一个线程,去对比用户配置中的时间,作出及时提醒。然后面试的时候在描述该做法时就被问到一个问题,如果Service被系统或者其他应用kill了怎么办?我...
分类:
移动开发 时间:
2014-05-19 15:48:37
阅读次数:
384
面向对象编程--再谈文本查询示例[续/习题]//P522 习题15.41
//1 in TextQuery.h
#ifndef TEXTQUERY_H_INCLUDED
#define TEXTQUERY_H_INCLUDED
#include
#include
#include
#include
#include
#include
#include
#include
usin...
分类:
编程语言 时间:
2014-05-18 18:41:59
阅读次数:
454
【题目】
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {...
分类:
其他好文 时间:
2014-05-18 10:37:57
阅读次数:
269
【题目】
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note:
Elements in a quadruplet (a,b,c,d) must be in non-descending ord...
分类:
其他好文 时间:
2014-05-18 08:46:04
阅读次数:
227
【题目】
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
【题意】
把罗马数转换为整数
【思路】
罗马数字中只使用如下七个基值字母:M,D,C,L,X,V,I,分别用来表示1000、500、100、50、10、5、1。
大体思路是每个罗马字母对应的值相加即可,
但需要处理900, 400, 90, 40, 9, 4这几个特殊...
分类:
其他好文 时间:
2014-05-18 07:58:54
阅读次数:
293
在lua中,可以通过元表来实现类、对象、继承等。与元表相关的方法有setmetatable()、__index、getmetatable()、__newindex。
具体什么是元表在这里就不细说了,网上很多介绍,这里主要讲与cocos2dx相关联的部分。
在lua-binding库中extern.lua里,有如下方法:
--Create an class.
function class(cl...
分类:
其他好文 时间:
2014-05-18 05:19:55
阅读次数:
298
【题目】
Write a function to find the longest common prefix string amongst an array of strings.
【题意】
求一组字符串的最长公共前缀
【思路】
使用归并思想求解
要求字符串[1,2,..,k,k+1,...n]的最大公共前缀,先分别求[1,2,...k]和[k+1,...,n]的公共前缀...
分类:
其他好文 时间:
2014-05-18 05:17:53
阅读次数:
232
面向对象编程--再谈文本查询示例引言: 扩展第10.6节的文本查询应用程序,使我们的系统可以支持更复杂的查询。 为了说明问题,将用下面的简单小说来运行查询: Alice Emma has long flowing red hair.
Her Daddy says when the wind blows
through her hair, it looks almost alive,
l...
分类:
编程语言 时间:
2014-05-18 04:15:13
阅读次数:
564
【题目】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
The so...
分类:
其他好文 时间:
2014-05-18 03:15:50
阅读次数:
287