Alright so I am trying to use wifstream to read from my .txt and put into my structure. I keep getting issues with this code: Please tell me what I need to know about it and why its failing. Thanks <3
I have 8 errors and they are all:
std::basic_istream<wchar_t,std::char_traits<wchar_t>>::getline': none of the 2 overloads could convert all the argument types
std::basic_istream<wchar_t,std::char_traits<wchar_t>>::getline': illegal call of non-static member function
std::basic_istream<wchar_t,std::char_traits<wchar_t>>::getline': illegal call of non-static member function
std::basic_istream<wchar_t,std::char_traits<wchar_t>>::getline': illegal call of non-static member function
a nonstatic member reference must be relative to a specific object
a nonstatic member reference must be relative to a specific object
a nonstatic member reference must be relative to a specific object
std::basic_ifstream<_Elem, _Traits>::getline [with _Elem=wchar_t, _Traits=std::char_traits<wchar_t>]" matches the argument list
Code:
#include "stdafx.h"
#include <Windows.h>
#include <Commctrl.h>
#include <Windowsx.h>
#include <shellapi.h>
#include <TlHelp32.h>
#include <wchar.h>
#include <fstream>
//SQL Headers
//Add SQL later with option to store games location.
//Macros Tab1
#define IDB_BUTTONLAUNCH 100
#define IDB_PROCESSCHECKBOX 101
//Macros Tab2
#define IDB_SQLRADIOBUTTON 201
#define IDB_NOTEPADRADIOBUTTON 202
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
int numberAdder = 0;
int *numberAdderPTR = &numberAdder;
struct gameSaved
{
int gameID = 0;
static wchar_t szGameDirectory[100];
static wchar_t szApplicationName[100];
static wchar_t szComboName[100];
};
wchar_t gameSaved::szGameDirectory[100];
wchar_t gameSaved::szApplicationName[100];
wchar_t gameSaved::szComboName[100];
gameSaved gameList[50];
void WndProc (etc) // This is just representing that it is all global.
{
std::wifstream savedGames;
savedGames.open(L"ComboBox Saved Games.txt");
//Error Code is with all the std::wifstream::getline below
while (std::wifstream::getline(gameList[numberAdder].gameID, 2))
{
std::wifstream::getline(gameList[numberAdder].szGameDirectory, MAX_PATH);
std::wifstream::getline(gameList[numberAdder].szApplicationName, MAX_PATH);
std::wifstream::getline(gameList[numberAdder].szComboName, MAX_PATH);
ComboBox_AddString(hComboBoxTab1, gameList[numberAdder].szComboName);
*numberAdderPTR = gameList[numberAdder].gameID + 1;
}
}
getline
is a non- static
member of std::wifstream
. Hence, it is not legal to use:
std::wifstream::getline( ... );
You need an object to make the call.
std::wifstream input;
input.getline( ... );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.