Organization of template classes

86 views Asked by At

I am writing a bunch of data structures and algorithms in C++ for practice (see github). I am currently writing a queue backed by a singly-linked list (that I created). If I need to include my linked list header file in the queue implementation, is it best to copy the linked list header into the queue folder for use?

I think it's important to note that all of my classes are templates, so based on this SO answer, I can't create a library that can be universally used.

I don't like the idea of copying the necessary header files into the directories so they work, so I'm hoping for a cleaner/better solution.

1

There are 1 answers

2
CinchBlue On BEST ANSWER

1) You can structure your file structure such that you can use relative paths: #include "../linked_list.h

2) Include the path of the header while compiling: -IPATH/TO/YOUR/FILE/FOLDER

Both of these are viable solutions, but I suggest you go with #2 because it works better if you decide to change file structure or want to reorganize the files. #2 is more flexible.