zoukankan      html  css  js  c++  java
  • .h file and function realization

    If we define a function in a .h file, compilating will succeed but

    every quoting cpp file will generate a part of .obj which realize this function.

    So Compile is OK  but Link will error out at multiple definition of a same function.

    Conclusion is that :  Function Declaration can be written in .h file.

               Never Function Definition be written in .h file. 

    The same reason,  Never Variable Definition Be Written in .h file.

    We can write them in .cpp as a global variable.

  • 相关阅读:
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    53.Maximum Subarray
  • 原文地址:https://www.cnblogs.com/stevenxiu/p/5761706.html
Copyright © 2011-2022 走看看