list Class in C++ -


I am working on a program that is considered to be reading the content of a file in the list of links "hypercard stack "(I have listed special).

I know that there is a list in the C ++ standard library, but since I've never worked with the standard library before, I do not know how to make it work with this particular problem for.

Any code I have received here has been successful in collecting bits of online bits and online tutorials together.

My .h file:

  // program6.h #include & lt; Iostream & gt; # Include & lt; Fstream & gt; #include & lt; String & gt; # Include & lt; List & gt; using namespace std; Square node {public: node (); Node (four code, integer number, string data); Node (node ​​and node); ~ Node (); Bool readFile (); Zero set next (node ​​* next); Zero print (); Private: four codes; Int Num; String data; Node * next; };  

My implementation file:

  // program6.cpp #include "program6.h" #include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; List & gt; using namespace std; Node :: node () {code = '\ 0'; Number = 0; Data = ""; Next = null; } Node :: node (four code, integer number, string data) {code = code; Number = number; Data = data; Next = null; } Node :: node (node ​​and node) {code = node. Code; Number = node. No; Data = node. Data; Next = null; } Node :: ~ node () {} bool node :: readFile () {char code = '\ 0'; Int num = 0; String data = ""; Ifstream inputfile; InputFile.open ("prog6.dat"); If (! Inputfile) {cerr & lt; & Lt; "Open Fails" & lt; & Lt; Endl; Exit (1); return false; } Node * head = null; While (! InputFile.eof ()) {inputFile> & Gt; Code & gt; & Gt; Points & gt; & Gt; Information; Node * temp = new node (code, number, data); Temp- & gt; SetNext (head); Head = temporary; } InputFile.close (); Head & gt; Print (); Back true; } Zero node :: SetDext (node ​​* next) {next = next; } Zero node :: print () {cout & lt; & Lt; Code & lt; & Lt; "" & Lt; & Lt; Number & lt; & Lt; "" & Lt; & Lt; Information; If (Next! = Null) Next-> Print (); }  

and my main / test file:

  // program6test.cpp #include "program6.h" #include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; List & gt; using namespace std; Int main () {node list; If (list.readFile ()) cout & lt; & Lt; "Success" & lt; & Lt; Endl; And cout & lt; & Lt; "Failure" & lt; & Lt; Endl; Return 0; }  

And this is a folded file that I need to read:

  i 27 Mary had a small lamb 15 Today is a good day i 35 Now is the time! I 9 This lab easy and fun PD 35 Ti 37 is better now FPHPD27D15D37D9I44 It should be this! Thanks for the reply below, I was getting rid of the "unspecified reference" errors which I was initially getting, though, here I am getting an error when I run the program  
  is terminated after throwing an example of 'st9bad_alloc' (): St9bad_alloc aborted  

Also, please keep in mind that when I am getting an error it needs to be solved, which is the question of The primary purpose is not to.

I am sorry if this is really comprehensive, then I really can not understand any of these, in reality it is not known how to further understand it. Can anyone help me to use the classroom to solve this problem, again, the features of this program can be found on the link I have already provided.

You need to put both files in GCC on the command line.

  [cs331129 @ cs ~] $ g ++ -o prog6 Program6test.cpp program6.cpp  

Note that you only have .cpp Files must be passed in the compiler, because it directs #include to header files.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -