【发布时间】:2014-02-07 10:54:01
【问题描述】:
我正在开发 GCC 4.8.1 下的 C++ 项目。我有两个 getter/setter 对:
LOGFONT GetTitleBarFont();
void SetTitleBarFont(LOGFONT titleBarFont);
std::wstring GetTitleBarFont();
void SetTitleBarFont(std::wstring titleBarFont);
但出于某种原因,GCC 告诉我这些不是有效的重载。
error: 'std::wstring GetTitleBarFont()' cannot be overloaded
error: with 'LOGFONT GetTitleBarFont()'
我不明白这里的问题是什么。 std::wstring 是一种 STL 类型(准确地说是std::basic_string<wchar_t>),在后台有大量模板工作。 LOGFONT 是一种 Windows 数据类型 (http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx),几乎完全由原生 C++ 数据类型(LONGs 和 BYTEs,带有一个奇怪的 TCHAR 数组)组成。这些怎么可能是模棱两可的重载?
【问题讨论】:
-
你不能重载返回类型。
标签: c++ gcc overloading