例如,GCC和鐺均不能編譯下面的代碼: struct S {};
namespace N
{
void g(S);
}
using N::g;
namespace N
{
void g(int);
}
int main()
{
g(0);
}
與錯誤: test.cpp: In function 'int main()':
test.
可能重複: In C++ how is function overloading typically implemented? 我所經歷的布魯斯Eckel的書OOPS,其中指出關於工作有關重載函數如果它們在返回值和參數傳遞方面有差異。 int fun() :: could be represented as __int__fun
float fun():: could be represente
我試圖阻止類B訪問DoSomething(Y類)函數並且只訪問DoSomething(類X)。我如何用C++來做到這一點? Class A {
public:
void DoSomething(Class Y);
}
Class B: public A {
public:
void DoSomething(Class X);
}
我有這樣的代碼: void Foo(int& a, string& b, vector<int>& c) {
... // 30 lines of code are same as another function
... // 10 lines of code to parse and assign value to vector<int>& c
}
void Foo(int& a,