• Register
1 vote
802 views

Problem :

I am very new to the C++programming, and so I keep facing the below error saying:

Reference to overloaded function could not be resolved; did you mean to call it?

 

Below is my code that is causing me all sorts of troubles :

#include <stdio.h>
#include <string>
using namespace std;


int main() {
    string myname;
    string myage;
    cout << "Enter the name and age: ";
    cin >> myname >> myage;
    cout << "Hello, " << myname << ", are you " << myage << " years old?\n";
    return 0;
}

I am currently using Xcode on my  Mac OS X Mojave.

I have also noticed that if I have only the current code, then it works very fine, but when I try to have multiple files, all of the files fail to work.

Can anyone explain me why my code is failing and can be the solution for it?

6 5 3
7,540 points

1 Answer

0 votes

Solution :

In your code the stdio.h does not define the std::cin and std::cout. That header only defines your C functions for the input and the output, like your printf and scanf. So it is the I/O header, but it is not the one you are looking for.

You need to simply include the <iostream> to have the std::cin and std::cout.

If you do above simple change your code will start giving you the desired output.

9 7 4
38,600 points

Related questions

0 votes
1 answer 6 views
6 views
I want to know how to call to an overloaded function be ambiguous.
asked Oct 4 Daniel Anderson 4k points
0 votes
1 answer 709 views
709 views
Problem: Installation failed: Can&rsquo;t Install the Software I am getting following message like: A software update is required to connect to your iPhone. Would you like to download and install this updatenow? Use of this software is subject to the original Software ... the software because it si not currently available from the softwre update server. Can any one help to sort this issue out?
asked Jul 16 quizzBabes 160 points
0 votes
1 answer 572 views
572 views
Problem : I got an error on Xcode saying that there was no information about the view controller as follows: Could not insert new outlet connection: Could not find any information for the class named Why am I getting this error?
asked Nov 28, 2019 alecxe 7.5k points
1 vote
1 answer 35 views
35 views
Problem: I am beginner to Swift and xcode. I have recently started working on the swift 2.3 project and then I simply updated it to swift 3.0 and all of a sudden my below working code stopped working. let mytask = URLSession.shared.datatask(with: request, ... have already spent a lot of time in debugging above code. Now I am looking for Swift expert who can help in fixing above error.
asked May 21 Martin K 6.6k points
0 votes
1 answer 48 views
48 views
Problem : A simple question for which I want to find the answer here. &ldquo;As parameters to a function, class objects can be passed by reference only.&rdquo; void myRefFunction(type myRefVariable) { } void main() {     myRefFunction(myRefVariable); } For a simple data ... object is passed rather than creating the copy and passing it. So question is does C++ pass the object by reference or value?
asked Jan 29 jwilliam 3.9k points