Having an assignment of one struct type variable to another, will the code compile?
template <class T>
struct S { };

struct A { };
struct B : A { };

void Test() {
  S<A> a;
  S<B> b;
  a = b;
No, since S<B> doesn't inherit S<A>, so compiler can't automatically generate a copy assignment operator.

Follow CodeGalaxy

Mobile Beta

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