Hello,
Compilation of the line "cout = outFile" throws error
"Error: std::ios_base::operator=(const std::ios_base&) is not accessible from std::ios ::operator=(const std::ios &)."
outFile is declared as "static ofstream".
Thanks,
Shafi
Hello,
Compilation of the line "cout = outFile" throws error
"Error: std::ios_base::operator=(const std::ios_base&) is not accessible from std::ios ::operator=(const std::ios &)."
outFile is declared as "static ofstream".
Thanks,
Shafi
What are you trying to achieve? If you want to redirect cout into a file, this won't work this way.
But if so, this should be enough to help you
This got compiled successfully using Sun 4.2 Compiler and the code is running also. Now with Sun 5.8 C++ compiler (SunStuio11) , there are restrictions..
I am trying to display the output in the console as shown below.
some thing like this ...
FILENAME bad_file;
static ofstream bad_log;
bad_log.open(bad_file, ios::out);
if (!bad_log)
{
cout<<"Can't open bad file - "<<bad_file<<" for write!"<<endl;
return FAIL;
}
//Error: std::ios_base::operator=(const std::ios_base&) is not accessible from std::ios ::operator=(const std::ios &).
cerr = bad_log;
iostream just uses the standard read/write/open/close functions at base, so you could try:
int fd=open("/path/to/file", O_WRONLY|O_CREAT);
dup2(fd, STDOUT_FILENO);
close(fd);