B. Dutton B. Dutton - 4 days ago 4x
C++ Question

C++ "No overloaded function takes 0 arguments" error

I have a program that is saving a username, and the read username function of it keeps giving this error:

Severity Code Description Project File Line Suppression State
Error C2661 'std::basic_ifstream>::open': no overloaded function takes 0 arguments ConsoleApplication3 c:\users\main\documents\visual studio 2015\projects\consoleapplication3\consoleapplication3\consoleapplication3.cpp 25

I am very new to C++ and don't understand what this error means, but I have my code here.

string name2()
string name2;
ifstream myfile("Userlog.txt");
myfile >> name2;
return name2;

string name2;
ifstream myfile("Userlog.txt"); // here you are calling open
myfile.open(); // no version of ifstream. so open what??!!!

the line above can be translated as:

ifstream myfile;
myfile >> name2;