What will be the result of code execution?
#include <iostream>

using namespace std;

template<class T>
struct Bar {
    
    T data;
   
    Bar(){  
        cout << "Default construct"<<endl;
    }
  
    template<class X> Bar(const Bar<X>& val) {
        
        data = val.data;
        cout << "Template copy construct"; 
    
    }
};

int main(){

   Bar<int> b1;

   Bar<int> b2(b1);

   Bar<double> b3(b1);

   cin.get();

   return 0;
}

Follow CodeGalaxy

Mobile Beta

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