I'm a computer science student at some university and we were given files to work on for hw.
And I wasn't sure how this kind of instantiation worked.
long code short it looked something like this.
in List.h
#ifndef _LIST_H_
#define _LIST_H_
#include
#include
template
class List
/* implementation below but not relevant to this post */
.
.
.
.
....the last few lines of the file below.
#include "list.cpp"
#include "list_given.cpp"
#endif
and List.cpp didn't include List.h
I don't understand how including List.cpp in the header file works.
Answer
#include just causes textual substitution, nothing else, so it's as if the entire contents of list.cpp were duplicated in the header file. This has nothing to do with "explicit template instantiation".
list.cpp doesn't include the header because otherwise the header would include itself recursively.
No comments:
Post a Comment