I'm kind of confused by ofstream. ofstream inherited from ostream. And it also inherited method "operator<<" from ostream.
ofstream x;
x << "hello world" << endl;
//cout << "hello world" << endl;
system("pause");
return 0;
The above code clip is trying to use an object of ofsream to output "hello world" to the terminal just as cout did.
The above code clip can compile but shows nothing. Why does it happen?
Thanks,
coutup to write to a terminal. It doesn't happen just by calling the default constructor, which is what you are doing with your objectx. - Benjamin Lindley