不完整类型incomplete type

不完整类型是一种用于描述标识符而无法确认该描述符大小的类型。


如一个类只有声明没有定义,一个数组没有指定大小等。

还有一种情况就是类有定义,但是所在头文件没有被包含文件A中,仅仅在A中声明了,也属于不完整类型。



在编码过程中可以利用“无法确认该描述符大小”的特点来保证代码安全,如

typedef char T_must_be_comlete_type[(0 == sizeof(T) ? -1 : 1)];

如果类型T是个不完整类型,那么sizeof(T)就等于0,相当于

typedef char T_must_be_comlete_type[-1];

数组大小为-1在编译期间就会报错。



  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
hapter 1:Refactoring,a First Example 重构,第一个例子   The Starting Point 起点   The First Step in Refactoring 重构第一步   Decomposing and Redistributing the Statement Method 分解并重组slalemenl方法   Replacing the Conditional Logic on Price Code with Polymorphism 用多态代替价格条件逻辑代码   Final Thoughts 结语  Chapter 2:Principles in Refactoring 重构原则   Defining Refactoring 何谓重构   Why Should You Refactor? 为何重构   When Should You Refactor? 何时重构   What Do I Tell My Manager? 怎样说服经理   Problems with Refactoring 重构的问题   Refactoring and Design 重构与设计   Refactoring and Performance 重构与性能   Where Did Refactoring Come From? 重构的起源  Chapter 3:Bad Smells in Code(by Kent Beck and Martin Fowler) 代码坏昧   Duplicated Code 重复代码   Long Method 过长方法   Large Class 过长类   Long Parameter List 过长参数列表   Divergent Change 发散式变化   Shotgun Surgery 霰弹式修改   Feature Envy 特性依恋   Data Clumps 数据泥团   Primitive Obsession 基本类型偏执   Switch Statements switch语句   Parallel Inheritance Hierarchies 平行继承体系   Lazy Class 冗余类   Speculative Generality 理论上的一般性   Temporary Field 临时字段   Message Chains 消息链   Middle Man 中间人   Inappropriate Intimacy 过度亲密   Alternative Classes with Different Interfaces 接口不同的等效类  Incomplete Library Class 不完整的库类   Data Class 数据类   Refused Bequest 拒绝继承   Comments 注释过多  Chapter 4:Building Tests 构建测试   The Value of Self-testing Code 自测试代码的重要性   The JUnit Testing Framework Junit测试框架   Adding More Tests 添加更多测试  Chapter 5:Toward a Catalog of Refactorings 重构目录   Format of the Refactorings 重构描述的格式   Finding References 寻找引用   How Mature Are These Refactorings? 这些重构的成熟度如何 Chapter 6:Composing Methods 组合方法   Extract Method 提取方法   Inline Method 内联方法   Inline Temp 内联临时变量   *Replace Temp with Query 用查询方法代替临时变量   Introduce Explaining Variable 引入解释性变量   Split Temporary Variable 分离临时变量   *Remove Assignments to Parameters 去除参数赋值   Replace Method with Method Object 用方法对象代替方法   Substitute Algorithm 替换算法  Chapter 7:Moving Features Between Objects 在对象之间移动特性  *Move Method 移动方法   Move Field 移动字段   Extract Class 提取类   Inline Class 内联类   Hide Delegate 隐藏委托类   Remove Middle Man 去除中间人   Introduce Foreign Method 引入外加方法   *Introduce Local Extension 引入本地扩展类  Chapter 8:Organizing Data 组织数据   Self Encapsulate Field 自封装字段   Replace Data Value with Object 用对象代替数据值   Change Value to Reference 将值对象改为引用对象   Change Reference to Value 将引用对象改为值对象   Replace Array with Object 用对象代替数组   Duplicate Observed Data 重复被观察数据   *Change Unidirectional Associationto Bidirectional 将单向关联改为双向   Change Bidirectional Association to Unidirectional 将双向关联改为单向   *Replace Magic Number with Symbolic Constant 用字面常量代替魔数   Encapsulate Field 封装字段   Encapsulate Collection 封装集合   Replace Record with Data Class 用数据类代替记录   *ReplaceType Code with Class 用类代替类型码   Replace Type Code with Subclasses 用子类代替类型码   Replace Type Code with State/Strategy用State/Strategy 代替类型码   Replace Subclass with Fields 用字段代替子类  Chapter 9:Simplifying Conditional Expressions 简化条件语句   Decompose Conditional 分解条件语句   Consolidate Conditional Expression 合并条件语句   Consolidate Duplicate Conditional Fragments 合并重复的条件片段   Remove Control Flag 去除控制标志   Replace Nested Conditional with Guard Clauses 用守卫语句代替嵌套条件语句   Replace Conditional with Polymorphism 用多态代替条件语句   Introduce Null Object 引入Null对象   Introduce Assertion 引入断言  Chapter 10:Making Method Calls Simpler 简化方法调用   Rename Method 重命名方法   Add Parameter 添加参数   Remove Parameter 去除参数   Separate query from Modifier 将查询方法与修改方法分离   Parameterize Method 参数化方法   Replace Parameter with Explicit Methods 用显式方法代替参数  Preserve Whole Object 保持对象完整   Replace Parameter with Method 用方法代替参数   Introduce Parameter Object 引入参数对象   Remove Setting Method 去除设置方法   Hide Method 隐藏方法   Replace Constructor with Factory Method 用工厂方法代替构造器   Encapsulate Downcast 封装向下转型   Replace Error Code with Exception 用异常代替错误码   Replace Exception with Test 用测试代替异常  Chapter 11:Dealing with Generalization 处理泛化关系   Pull Up Field 上移字段   Pull UP Method 上移方法   Pull Up Constructor Body 上移构造器主体   Push Down Method 下移方法   Push Down Field 下移字段   Extract Subclass 提取子类   Extract Superclass 提取超类   Extract Interface 提取接口   Collapse Hierarchy 合并继承层次   Form Template Method 形成Template Method   Replace Inheritance with Delegation 用委托代替继承   Replace Delegation with Inheritance 用继承代替委托  Chapter 12:Big Refactorings(by Kent Beck and Martin Fowler) 大型重构   Tease Apart Inheritance 分解继承层次   Convert Procedural Design to Objects 将过程式设计转换为面向对象   Separate Domain from Presentation 将领域逻辑与表现分离   Extract Hierarchy 提取继承层次  Chapter 13:Refactoring,Reuse,and Reality(by William Opdyke) 重构,复用与现实   A Reality Check 现实的检验   Whv Are Developers Reluctant to Refactor Their Programs? 开发人员为何不愿重构程序   A Reality Check(Revisited) 再谈现实的检验   Resources and References for Refactoring 重构的资源和参考文献   Implications Regarding Software Reuse and Technology Transfer 对软件复用与技术传播的意义   A Final Note 结语   References 参考文献  Chapter 14:Refactoring Tools(by Don Roberts and John Brant) 重构工具   Refactoring with a Tool 使用工具重构   Technical Criteria for a Refactoring Tool 重构工具的技术标准   Practical Criteria for a Refactoring Tool 重构工具的实用标准   Wrap Up 结语  Chapter 15:Putting It All Together(by Kent Beck) 集大成  References参考文献  List of Soundbites 要点列表  Updates 更新内容  Index 索引
hapter 1:Refactoring,a First Example 重构,第一个例子   The Starting Point 起点   The First Step in Refactoring 重构第一步   Decomposing and Redistributing the Statement Method 分解并重组slalemenl方法   Replacing the Conditional Logic on Price Code with Polymorphism 用多态代替价格条件逻辑代码   Final Thoughts 结语  Chapter 2:Principles in Refactoring 重构原则   Defining Refactoring 何谓重构   Why Should You Refactor? 为何重构   When Should You Refactor? 何时重构   What Do I Tell My Manager? 怎样说服经理   Problems with Refactoring 重构的问题   Refactoring and Design 重构与设计   Refactoring and Performance 重构与性能   Where Did Refactoring Come From? 重构的起源  Chapter 3:Bad Smells in Code(by Kent Beck and Martin Fowler) 代码坏昧   Duplicated Code 重复代码   Long Method 过长方法   Large Class 过长类   Long Parameter List 过长参数列表   Divergent Change 发散式变化   Shotgun Surgery 霰弹式修改   Feature Envy 特性依恋   Data Clumps 数据泥团   Primitive Obsession 基本类型偏执   Switch Statements switch语句   Parallel Inheritance Hierarchies 平行继承体系   Lazy Class 冗余类   Speculative Generality 理论上的一般性   Temporary Field 临时字段   Message Chains 消息链   Middle Man 中间人   Inappropriate Intimacy 过度亲密   Alternative Classes with Different Interfaces 接口不同的等效类  Incomplete Library Class 不完整的库类   Data Class 数据类   Refused Bequest 拒绝继承   Comments 注释过多  Chapter 4:Building Tests 构建测试   The Value of Self-testing Code 自测试代码的重要性   The JUnit Testing Framework Junit测试框架   Adding More Tests 添加更多测试  Chapter 5:Toward a Catalog of Refactorings 重构目录   Format of the Refactorings 重构描述的格式   Finding References 寻找引用   How Mature Are These Refactorings? 这些重构的成熟度如何 Chapter 6:Composing Methods 组合方法   Extract Method 提取方法   Inline Method 内联方法   Inline Temp 内联临时变量   *Replace Temp with Query 用查询方法代替临时变量   Introduce Explaining Variable 引入解释性变量   Split Temporary Variable 分离临时变量   *Remove Assignments to Parameters 去除参数赋值   Replace Method with Method Object 用方法对象代替方法   Substitute Algorithm 替换算法  Chapter 7:Moving Features Between Objects 在对象之间移动特性  *Move Method 移动方法   Move Field 移动字段   Extract Class 提取类   Inline Class 内联类   Hide Delegate 隐藏委托类   Remove Middle Man 去除中间人   Introduce Foreign Method 引入外加方法   *Introduce Local Extension 引入本地扩展类  Chapter 8:Organizing Data 组织数据   Self Encapsulate Field 自封装字段   Replace Data Value with Object 用对象代替数据值   Change Value to Reference 将值对象改为引用对象   Change Reference to Value 将引用对象改为值对象   Replace Array with Object 用对象代替数组   Duplicate Observed Data 重复被观察数据   *Change Unidirectional Associationto Bidirectional 将单向关联改为双向   Change Bidirectional Association to Unidirectional 将双向关联改为单向   *Replace Magic Number with Symbolic Constant 用字面常量代替魔数   Encapsulate Field 封装字段   Encapsulate Collection 封装集合   Replace Record with Data Class 用数据类代替记录   *ReplaceType Code with Class 用类代替类型码   Replace Type Code with Subclasses 用子类代替类型码   Replace Type Code with State/Strategy用State/Strategy 代替类型码   Replace Subclass with Fields 用字段代替子类  Chapter 9:Simplifying Conditional Expressions 简化条件语句   Decompose Conditional 分解条件语句   Consolidate Conditional Expression 合并条件语句   Consolidate Duplicate Conditional Fragments 合并重复的条件片段   Remove Control Flag 去除控制标志   Replace Nested Conditional with Guard Clauses 用守卫语句代替嵌套条件语句   Replace Conditional with Polymorphism 用多态代替条件语句   Introduce Null Object 引入Null对象   Introduce Assertion 引入断言  Chapter 10:Making Method Calls Simpler 简化方法调用   Rename Method 重命名方法   Add Parameter 添加参数   Remove Parameter 去除参数   Separate query from Modifier 将查询方法与修改方法分离   Parameterize Method 参数化方法   Replace Parameter with Explicit Methods 用显式方法代替参数  Preserve Whole Object 保持对象完整   Replace Parameter with Method 用方法代替参数   Introduce Parameter Object 引入参数对象   Remove Setting Method 去除设置方法   Hide Method 隐藏方法   Replace Constructor with Factory Method 用工厂方法代替构造器   Encapsulate Downcast 封装向下转型   Replace Error Code with Exception 用异常代替错误码   Replace Exception with Test 用测试代替异常  Chapter 11:Dealing with Generalization 处理泛化关系   Pull Up Field 上移字段   Pull UP Method 上移方法   Pull Up Constructor Body 上移构造器主体   Push Down Method 下移方法   Push Down Field 下移字段   Extract Subclass 提取子类   Extract Superclass 提取超类   Extract Interface 提取接口   Collapse Hierarchy 合并继承层次   Form Template Method 形成Template Method   Replace Inheritance with Delegation 用委托代替继承   Replace Delegation with Inheritance 用继承代替委托  Chapter 12:Big Refactorings(by Kent Beck and Martin Fowler) 大型重构   Tease Apart Inheritance 分解继承层次   Convert Procedural Design to Objects 将过程式设计转换为面向对象   Separate Domain from Presentation 将领域逻辑与表现分离   Extract Hierarchy 提取继承层次  Chapter 13:Refactoring,Reuse,and Reality(by William Opdyke) 重构,复用与现实   A Reality Check 现实的检验   Whv Are Developers Reluctant to Refactor Their Programs? 开发人员为何不愿重构程序   A Reality Check(Revisited) 再谈现实的检验   Resources and References for Refactoring 重构的资源和参考文献   Implications Regarding Software Reuse and Technology Transfer 对软件复用与技术传播的意义   A Final Note 结语   References 参考文献  Chapter 14:Refactoring Tools(by Don Roberts and John Brant) 重构工具   Refactoring with a Tool 使用工具重构   Technical Criteria for a Refactoring Tool 重构工具的技术标准   Practical Criteria for a Refactoring Tool 重构工具的实用标准   Wrap Up 结语  Chapter 15:Putting It All Together(by Kent Beck) 集大成  References参考文献  List of Soundbites 要点列表  Updates 更新内容  Index 索引
1 Unassiagned number(未分配的号码(空号)) 3 No route to destination(无至目的地的路由) 6 Channel unacceptable(不可接受的信道) 16 Normal clearing(正常清除) 17 User busy(用户忙) 18 No user responding(无用户响应) 19 User alerting,no answer(已有用户提醒,但无应答) 21 Call rejected(呼叫拒绝) 22 Number changed(号码改变) 26 Non selected user clearing(清除未选择的用户) 27 Destination out of order(终点故障) 28 Incomplete number(无效号码格式(不完全的号码)) 29 Facility rejected(设施被拒绝) 30 Response to status enquiry(对状态询问的响应) 31 Normal,unspecified(正常,未规定) 34 No circuit/channel available(无电路/信道可用) 38 Network out of order(网络故障) 41 Temporary failure(临时故障) 42 Switching equipment congestion(交换设备拥塞) 43 Access information discarded(接入信息被丢弃) 44 Requested circuit/channel not available(请求的电路/信道不可用) 47 Resources unavailable,unspecified(资源不可用,未规定) 49 Quality of service unavailable(服务质量不可用) 50 Requested facility not subscribed(未预订所请求的设施) 55 Incoming calls barred within the CUG 57 Bearer capability not authorized(承载能力未认可) 58 Bearer capability not presently available(承载能力目前不可用) 63 Service or option not available,unspecified(无适用的业务或任选项目,未规定) 65 Bearer service not implemented(承载业务不能实现) 68 ACM equal to or greater than ACMmax 69 Requested facility not implemented(所请求的设施不能实现) 70 Only restricted digital information bearer(仅能获得受限数字信息承载能力) 79 Service or option not implemented(业务不能实现,未规定) 81 Invalid transaction identrfier value(无效处理识别码) 87 User not member of CUG 88 Incompatible destination(非兼容目的地址) 91 Invalid mandatory information(无效过渡网选择) 95 Semantically incorrect message(无效消息,未规定) 96 Invalid mandatory information(必选消息单元差错) 97 Message type non-existent or not implemented(消息类型不存在或不能实现) 98 Message type not compatible with protocol state(消息与控制状态不兼容,消息类型不存在或不能实现) 99 Information element non-existent or not implemented(信息单元不存在或不能实现) 100 Conditional IE error(无效信息单元内容) 101 Message not compatible with protocol state(消息与呼叫状态不兼容) 102 Recovery on timer expiry(定时器超时恢复) 111 Protocol error,unspecified(协议差错,未规定) 127 Interworking,unspecified(互通,未规定)
重构,一言以蔽之,就是在不改变外部行为的前提下,有条不紊地改善代码。多年前,正是本书原版的出版,使重构终于从编程高手们的小圈子走出,成为众多普通程序员日常开发工作中不可或缺的一部分。本书也因此成为与《设计模式》齐名的经典著作,被译为中、德、俄、日等众多语言,在世界范围内畅销不衰。 本书凝聚了软件开发社区专家多年摸索而获得的宝贵经验,拥有不因时光流逝而磨灭的价值。今天,无论是重构本身,业界对重构的理解,还是开发工具对重构的支持力度,都与本书最初出版时不可同日而语,但书中所蕴涵的意味和精华,依然值得反复咀嚼,而且往往能够常读常新。 第1章 重构,第一个案例 1.1 起点 1.2 重构的第一步 1.3 分解并重组statement() 1.4 运用多态取代与价格相关的条件逻辑 1.5 结语 第2章 重构原则 2.1 何谓重构 2.2 为何重构 2.3 何时重构 2.4 怎么对经理说 2.5 重构的难题 2.6 重构与设计 2.7 重构与性能 2.8 重构起源何处 第3章 代码的坏味道 3.1 Duplicated Code(重复代码) 3.2 Long Method(过长函数) 3.3 Large Class(过大的类) 3.4 Long Parameter List(过长参数列) 3.5 Divergent Change(发散式变化) 3.6 Shotgun Surgery(霰弹式修改) 3.7 Feature Envy(依恋情结) 3.8 Data Clumps(数据泥团) 3.9 Primitive Obsession(基本类型偏执) 3.10 Switch Statements(switch惊悚现身) 3.11 Parallel InheritanceHierarchies(平行继承体系) 3.12 Lazy Class(冗赘类) 3.13 Speculative Generality(夸夸其谈未来性) 3.14 Temporary Field(令人迷惑的暂时字段) 3.15 Message Chains(过度耦合的消息链) 3.16 Middle Man(中间人) 3.17 Inappropriate Intimacy(狎昵关系) 3.18 Alternative Classes with Different Interfaces(异曲同工的类) 3.19 Incomplete Library Class(不完美的库类) 3.20 Data Class(纯稚的数据类) 3.21 Refused Bequest(被拒绝的遗赠) 3.22 Comments(过多的注释) 第4章 构筑测试体系 4.1 自测试代码的价值 4.2 JUnit测试框架 4.3 添加更多测试 第5章 重构列表 5.1 重构的记录格式 5.2 寻找引用点 5.3 这些重构手法有多成熟 第6章 重新组织函数 6.1 Extract Method(提炼函数) 6.2 Inline Method(内联函数) 6.3 Inline Temp(内联临时变量) 6.4 Replace Temp with Query(以查询取代临时变量) 6.5 Introduce Explaining Variable(引入解释性变量) 6.6 Split Temporary Variable(分解临时变量) 6.7 Remove Assignments to Parameters(移除对参数的赋值) 6.8 Replace Method with Method Object(以函数对象取代函数) 6.9 Substitute Algorithm(替换算法) 第7章 在对象之间搬移特性 7.1 Move Method(搬移函数) 7.2 Move Field(搬移字段) 7.3 Extract Class(提炼类) 7.4 Inline Class(将类内联化) 7.5 Hide Delegate(隐藏“委托关系”) 7.6 Remove Middle Man(移除中间人) 7.7 Introduce Foreign Method(引入外加函数) 7.8 Introduce Local Extension(引入本地扩展) 第8章 重新组织数据 8.1 Self Encapsulate Field(自封装字段) 8.2 Replace Data Value with Object(以对象取代数据值) 8.3 Change Value to Reference(将值对象改为引用对象) 8.4 Change Reference to Value(将引用对象改为值对

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值