【发布时间】:2019-06-01 02:44:06
【问题描述】:
我是 C++ 新手,但一直收到错误消息:
无法解析对重载函数的引用;你的意思是这样称呼它吗?
以下是导致此问题的代码:
#include <stdio.h>
#include <string>
using namespace std;
int main() {
string name;
string age;
cout << "Enter your name and age: ";
cin >> name >> age;
cout << "Hello, " << name << ", are you " << age << " years old?\n";
return 0;
}
我在 Mac OS X Mojave 上使用 Xcode。
我还注意到,如果我只有那个代码,那么它工作得很好,但是当我有多个文件时,它们都不能工作。
谁能告诉我这是为什么以及解决方案?
【问题讨论】:
-
请阅读minimal reproducible examples。就目前而言,您的问题基本上无法回答:我们只能猜测您的问题可能是什么。 This is a discussion that may also be relevant in your case.
-
您需要包含
<iostream>才能使用std::cin和std::cout。