![]() |
| ||
| Using a class to add/delete/show numbers in a Link List I have this program that is supposed to take in numbers from the Main cpp file and add them to the link list. Eventually i have to sort them then display them on the screen. For right now i am just trying to insert them to the link list but i keep getting a complie error. I am trying to compile this program and i get the following error "'[HTML]Node' : no appropriate default constructor available[/HTML]" Any suggestions ? I have attached a link to the files in case it is easier for you to view it that way Project 3 Thanks Here is my .h file which creates the file currently i am trying to get the Insert Fuction to work so i have the other set as commetns //--------------------------------------------------------------------------- Here is my implemtation file which define the functions in the class: #include <iostream> Finally here is my Main CPP file
|
| ||
| Re: Using a class to add/delete/show numbers in a Link List >Node *newPtr = new Node ; You're trying to use a constructor with no arguments, yet your Node is declared as: struct NodeNotice how the only constructor declared takes two arguments. If you declare any constructors then the default constructor is not created automagically for you. >Any suggestions ? Be prepared for a good time trying to get this program to work. :mrgreen: |
| ||
| Re: Using a class to add/delete/show numbers in a Link List does anyone have any hits on how i can redo the implemenation of Insert to get this to work ? Thanks |
| ||
| Re: Using a class to add/delete/show numbers in a Link List >does anyone have any hits on how i can redo the implemenation of Insert to get this to work ? Don't use recursion. Not only does it complicate a simple algorithm, it's potentially dangerous for long lists. I generally prefer to avoid recursion for linear data structures. If you can't efficiently divide the structure in half then that's an indication that recursion may not be the best solution. #include <cstdlib> |
| All times are GMT -4. The time now is 9:35 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC