Streams and Pointers

Look at the following program. It compiles correctly under every standard-conforming compiler. At first, this may seem surprising because seemingly, because it’s impossible delete an object which is not a pointer and still, the delete expression takes a reference as its argument:

 #include #include using namespace std;int main(){ ifstream &i = *new ifstream("myfile.txt");//

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: