代碼如下,如何在成員函式中呼叫同名的成員函式?
class A
{
public:
void print(const std::string &str)
{
std::cout<<str<<std::endl;
}
void print()
{
//如何在該函式中呼叫print(const std::string&)
}
};
uj5u.com熱心網友回復:
A a;a.print("123");//printf(string);
a.print();//print();
根據引數匹配。
uj5u.com熱心網友回復:
直接調就行了啊,傳個引數。uj5u.com熱心網友回復:
都不審題,是讓在print()中呼叫print(std::string).
uj5u.com熱心網友回復:
都不審題,是讓在print()中呼叫print(std::string).
uj5u.com熱心網友回復:
不會舉一反三?
void print(){
this->print("foo");
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/281454.html
標籤:C++ 語言
上一篇:網測題
