我在测试书上的例子时,按书上把类的构造器前加了inline,main函数和类的实现不在同一个文件中,在测试时报了如下错误:
1>Main.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall UserProfile::UserProfile(void)" (??0UserProfile@@QAE@XZ),该符号在函数 _main 中被引用
1>Main.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall UserProfile::UserProfile(class std::basic_string,class std::allocator >,enum UserProfile::uLevel)" (??0UserProfile@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4uLevel@0@@Z),该符号在函数 _main 中被引用
1>D:\Visual Studio 2015\Projects\STLStudy\Debug\STLStudy.exe : fatal error LNK1120: 2 个无法解析的外部命令
我把inline去掉或是把main函数放在类的实现的文件中时,就可以正常运行了。想知道为什么。编译器是vs2015