If I have a templated class definition in list.h:
template <class T>;
class list {
list *next;
T *data;
list(T *data){
this->next = NULL;
this->data = data;
}
void concat(T *data){
this->concat(new list<T>(data));
}
void concat(list<T> *sublist){
if (this->next != NULL){
this->next->concat(sublist);
} else {
this->next = sublist;
}
}
}
Then if I have main.cpp:
class bar {
bar(){
}
}
class baz {
baz(){
}
}
void main(){
new list<bar>(new bar());
new list<baz>(new baz());
}
And then I ran:
gcc -c main.cpp
- How does the code get put into translation units?
- Does the translation unit of main.cpp have 2 versions of list?
- What if list we included in another translation unit, would it appear in both?