why inline functions must be put in header files?

  编译中有2个过程:compile、link。先进行compile,compile中把源代码编译成目标代码(.obj),然后是link,把目标代码(obj)中的外部符号替换为真实的地址。

  inline函数的作用是减少函数调用而直接使用函数内部内容,显示是发生在compile阶段。所以如果把inline函数放在cc文件中,则compile过程中无法实现inline效果,连接器将给出 “unresolved external” 。

  事实上,inline一个函数,也意味着给该函数加上了static标签。

  参考:http://www.cnblogs.com/mydomain/archive/2013/04/06/3001859.html

why inline functions must be put in header files?的更多相关文章

  1. Inline functions

    Problems: (Page 372) There are two problems with the use of proprocessor macros in C++. The first is ...

  2. C++对象模型——Inline Functions(第四章)

    4.5 Inline Functions 以下是Point class 的一个加法运算符的可能实现内容: class Point { friend Point operator+(const Poin ...

  3. 解决Cannot find MySQL header files under /usr/include/mysql的错误

    按照下面的步骤能成功,亲测.转帖,做笔记 编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. ...

  4. TN035: Using Multiple Resource Files and Header Files with Visual C++

    TN035: Using Multiple Resource Files and Header Files with Visual C++ This note describes how the Vi ...

  5. VC中Source Files, Header Files, Resource Files,External Dependencies的区别

    VC中Source Files, Header Files, Resource Files,External Dependencies的区别 区别: Source Files 放源文件(.c..cpp ...

  6. 编译安装php Cannot find MySQL header files under /usr/include/mysql.

    编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. Note that the MySQL c ...

  7. Unable to find the ncurses libraries or the required header files解决

    问题: 解决方法: sudo apt-get install ncurses-dev 参考:Unable to find the ncurses libraries or the required h ...

  8. 编译安装php时提示Cannot find MySQL header files的解决方法

    php的配置文件中有一行--with-mysql=/usr/local/mysql ,安装的时候提示:configure: error: Cannot find MySQL header files ...

  9. [转载]C header files matching your running 

    原文地址:C header files matching your running kernel were not found.作者:[Opser]小默 c header files matching ...

随机推荐

  1. STL的集合set

    集合: 集合是由元素组成的一个类,其成员可以是一个集合,也可以是一个原子,通常一个元素在一个集合中不能多次出现:由于对实现集合不是很理解,只简单写下已有的STL中的set集合使用: C++中set基本 ...

  2. Tween.js 动画效果

    一.apply,和call的用法. 先来一个与本次博文无关的东西,就是apply和call的用法.其实apply和call的用法都一样,只是他们的传参不一样.apply是数组,而call是单独的传,类 ...

  3. 将utf-8的中文或者字符都看成一个字符

    function utf8_strlen($string=null){ // 将字符串分解为单元 preg_match_all("/./us", $string, $match); ...

  4. Windows 10 正式版原版ISO镜像

    Win10正式版32位简体中文版(含家庭版.专业版)文件名: cn_windows_10_multiple_editions_x86_dvd_6846431.isoSHA1:21B824F402927 ...

  5. python自动化之邮件发送

    #!/usr/bin/env python # -*- coding:utf-8 -*- import smtplib from email.mime.multipart import MIMEMul ...

  6. Python中用dict统计列表中元素出现的次数

    01 Python增加元素,不像其他语言使用现实的操作接口,只需要dict[1]=3,如果字典中不存在1,则直接新增元素键值对(1,3),如果存在则替换键1为3. if key in dict:判断出 ...

  7. linux eclipse add desktop shortcut with root permission

    gedit ~/.local/share/applications/opt_eclipse.desktop sudo apt-get install gksu [Desktop Entry] Type ...

  8. Oracle 双字段过滤

    白名单:数据 id ,  g_id,sys_id 1,2,3 1,2,4   黑名单:数据 id ,  g_id,sys_id b,2,3   结果  1,2,4      select t1.*   ...

  9. 一些$LCT$的瓜皮题目

    一些瓜皮 放几个比较优(she)秀(pi)的\(LCT\)题. 老惯例,每一题代码因为一些未知原因消失了(如果要的话私我好了,虽然会咕咕咕). 嘴巴\(AC\)真香! [SP16580] QTREE7 ...

  10. 【BZOJ4903/UOJ300】【CTSC2017】吉夫特

    Description 传送门 ​ 简述题意:给一个序列,询问有多少子序列满足其中不会出现\(a\choose b\)是偶数的情况,其中\(a\)在\(b\)前面. Solution 首先探究组合数的 ...