1
我不知道类似的问题之前问过,但我不能知道如何寻找它,重复的标记是值得欢迎的一个功能,如果你给我提供一个链接:)整数输入给需要const引用
,所以我请问:
#include <iostream>
class H
{
public:
H(int x = 0)
{
std::cout << "constructor";
}
};
void func1(const H &a1)
{
}
int main()
{
func1(15);
return 0;
}
你能解释一下这里发生了什么吗?为什么它接受int值作为const引用,调用构造函数等?
谢谢。