c++ - How should I create a files just for functions? -


I am creating a BST class and I want to put transceral functions (inser, preder, post order, levelcane) separately File. I am unsure about how to go about this. I tried to make an .h file but it was not working since it is not really a definition of a class, should I still make a traversal class ? Or go straight to the function definitions?

  #ifndef TREETRAV_H # Define TREETRAV_H #Include "TreeNode.h" #includes & lt; Iostream.h & gt; # Include & lt; Stdlib.h & gt; Template & lt; Class T & gt; Class Treatment {Buddy class Binistry & lt; T & gt; Public: Order zero before (treenode * t, zero travel (t and item)); Zero InOrderVisit (TreeNode * T, Zero Travel (T & amp; Item)); Zero post order visit (tree node * t, zero travel (t and item)); Zero LevelScan (tree node * t, zero travel (t & amp; item)); }; #endif  

Since trace is a class template, This class can not apply to different CPP files. This will not work. The template will follow the 2-step compilation process. The first step will check the basic syntax (such as for loop usage, proper bracket etc.) The second step is actually the template type Will be compiled against. Therefore, the .cpp file will only contain the first steps of the compilation, and later you will get the linker errors (for example, TreeTrav is not defined by gt; foo ).

It would be better to apply only all the square (template) in the header file. Or you can include # at the end of this header file & lt; Cpp-file-name & gt; must be placed.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -