Let us assume this small piece of code:
#include<iostream>
template <typename T>
class A {
T a;
};
int main() {
A<int> a;
A<char> c;
}
Now, consider this code where instead of templates, I have two separate classes for int and char.
#include<iostream>
class A {
int a;
};
class C {
char c;
};
int main() {
A a;
C c;
}
Would there be any difference in the above two approaches as per compiler, optimization or code segment of the program?
In which approach executable size would be larger and why?