Duplicate Symbol in nested namespace

喜欢而已 提交于 2019-12-02 10:58:08

#pragma once makes sure the header file is only included once in each translation unit it's included in. So if you include it in more than one cpp file, you will get multiple implementations.

Declare your functions inline e.g. :

inline unsigned int getNextUInt(std::istream &is)
{
    ...
}

Or, put the function implementations in a cpp file.


The variables have to be defined in a cpp file. In the header file, you will have this:

extern unsigned int uintBuffer;

and in the cpp file you have this:

unsigned int uintBuffer;

All of this becomes easier when you use classes instead of global variables and functions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!