What happens if you try to run this code?
#include <memory>
#include <iostream>
using namespace std;

auto_ptr<int> func(auto_ptr<int> a)
{
    *a*=2;
    return a;
}

int main ( int argc, char * argv [] )
{
    auto_ptr<int> ptr(new int(2));
    func(ptr);
    cout << *ptr;
    
    return 0;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes