mercredi 11 mai 2022

In C file one pointer can be assigned to another file pointer but not in C++ ifstream

error: use of deleted function ‘std::basic_ifstream<_CharT, _Traits>& std::basic_ifstream<_CharT, _Traits>::operator=(const std::basic_ifstream<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]’
   92 |    logfp = logfptemp;

Below is C file pointers:

FILE *logfptemp = NULL;
FILE *logfp;
logfptemp  = fopen(logger.path, "w+");
logfp = logfptemp ;

It’s valid but below is C++ ifstream:

std::ifstream logfp;
std::ifstream logfptemp;
logfp = logfptemp ;

It’s not valid.

Aucun commentaire:

Enregistrer un commentaire