//Node.cpp #include <iostream> using namespace std; template<typename T> class Node { public: T Val; Node<T> *Next; Node(T value):Val(value){}; };
//h2.cpp #include <iostream> #include <iterator> #include <ctime> #include <random> #include <vector> #include "List.h" #include "Node.cpp" template<typename T> void printNode(Node<T> *node) { while(node!=nullptr) { cout<<node->Val<<"->"; node=node->Next; } cout<<"NULL"<<endl; } void nodeT9(); int main() { nodeT9(); return 0; } void nodeT9() { Node<float> *node1=new Node<float>(3.14); Node<float> *node2=new Node<float>(6.28); Node<float> *node3=new Node<float>(9.42); node1->Next=node2; node2->Next=node3; printNode(node1); cout<<"Finished in node9()"<<endl; }
g++ -g -std=c++2a -I. h2.cpp Node.cpp -o h1
Run ./h1