C++中definition与declaration的区别
转载注明来源地址:http://blog.csdn.net/lastsweetop/article/details/49336221
翻了好几篇关于definition与declaration和博客,都写的很坑人 ,看来我得写一篇了,避免很多新手一入门就被坑了。
definition是通过declaration完整的定义了实体,每个declaration都是definition,除了下面几种情况。
1,存储类标识符extern开头的或者语言连接标识符开头,但未初始化的。
extern const int a; // declares, but doesn't define a extern const int b = 1;// defines b
extern "C" void f1(void(*pf)()); // declares a function f1 with C linkage,
2.没有函数体的函数
int f(int); // declares, but doesn't define f
3.函数中未定义的参数
int f(int x); // declares, but doesn't define f and x int f(int x) { // defines f and xreturn x+a; }
4.类中声明的静态变量
struct S { // defines Sint n; // defines S::nstatic int i; // declares, but doesn't define S::i }; int S::i; // defines S::i
5.只申明了类的名字,主要用在forward declaration和elaborated type中
struct S; // declares, but doesn't define S class Y f(class T p); // declares, but doesn't define Y and T (and also f and p)
6.模板参数
template<typename T> // declares, but doesn't define T
7.预先申明的模板
template<> struct A<int>; // declares, but doesn't define A<int>
8.typedef声明
typedef S S2; // declares, but doesn't define S2 (S may be incomplete)
9.alias申明
using S2 = S; // declares, but doesn't define S2 (S may be incomplete)
10.模糊enum的申明
enum Color : int; // declares, but doesn't define Col
11.Using-declaration
using N::d; // declares, but doesn't define d
C++中definition与declaration的区别相关推荐
- App测试中ios和Android的区别1
App测试中ios和Android的区别: 一.多分辨率测试 1.手机常见分辨率: 4:3 VGA 640*480 (Video Graphics Array) QVGA 320*240 ( ...
- 在循环之前或循环中声明变量之间的区别?
本文翻译自:Difference between declaring variables before or in loop? I have always wondered if, in genera ...
- python中break和continue的区别
python中break和continue的区别 break 结束for 或者while 循环 后面还没循环到的 不再循环 continue 当满足某种条件时结束当前值的循环 后面没有循环的继续循环 ...
- java中separator_java - File.separator和路径中的斜杠之间的区别
java - File.separator和路径中的斜杠之间的区别 在Java Path-String中使用/和普通的File.separator有什么区别? 与双反斜杠相比,/平台独立似乎不是原因, ...
- PHP中self和static的区别,php中self与static的区别
原文链接,猛击这里. php中self与static的区别 通过一些示例,我们可以很容易看出self和static的区别.假定我们有class Car – 它有两个方法,model和getModel. ...
- php 抽象类 接口 区别,PHP中抽象类、接口的区别与选择分析
本文实例分析了PHP中抽象类.接口的区别与选择.分享给大家供大家参考,具体如下: 区别: 1.对接口的使用是通过关键字implements.对抽象类的使用是通过关键字extends.当然接口也可以通过 ...
- php $this self,php中self与$this的区别
学习php中self与$this的区别. 先来看下parent与self的例子: /* * parent与self的区别 * by www.jbxue.com */ class A{ function ...
- mysql中char与varchar的区别分析(补充一句,int和integer没区别)
转自:http://www.jb51.net/article/23575.htm 在mysql教程中char与varchar的区别呢,都是用来存储字符串的,只是他们的保存方式不一样罢了,char有固定 ...
- python中bytearray和java中byte[]的区别_Python经典面试题:说说Python中xrange和range的区别?...
昨晚一小伙后台问xrange和range有啥区别,讲了下他倒领悟的挺快,其实这也是你各面试Python岗位,经常会遇到的Python面试题,长个心眼哈,说不定明年3月你找工作就用上了. 废话不多说,开 ...
最新文章
- Java中的多线程你只要看这一篇就够了
- 火蚁机器人_适度偷懒提高整体效率:火蚁工作方式启发机器人群组协作
- ADAS视觉方案盘点下篇:11家创业公司完全解读
- mysql联合索引顺序调整_MySQL 关于联合索引的字段顺序规则讨论
- ajax 传递arraybuffer,jQuery $ .ajax或$ .load是否允许responseType arrayBuffer?
- 基于字典SR各种方法【稀疏编码多种方法】
- 定位html中的背景图,关于背景图的定位和透明度问题(HTML+CSS笔记)
- Android学习——Fragment动态加载
- C# 比较两个数组中的内容是否相同的算法
- 数据结构题集第一章(严蔚敏)
- 简单实用口才训练方法集
- ET Reporter
- python解析pdf中文乱码_Python解决中文乱码.pdf
- hive为什么insert into后数据被覆盖了
- 申请工作居住证政策解答
- goland-gopath
- [POI2005]DWU-Double-row
- koa - 洋葱模型浅析
- 深入理解JVM(一)
- Type-C Layout 指南