devxlogo

Streams and Pointers

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");//

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist