ok now I'm down this one error message and i dont know what i am suppossed to do error C2244: 'LinkedList::displayList' : unable to match function definition to an existing declaration
LilKoopa
Posts
-
Help with a Linked List Program -
Help with a Linked List Programyes, and i get the following error messages. linkedlist.h(47) : error C2065: 'newNode' : undeclared identifier linkedlist.h(43) : while compiling class template member function 'void LinkedList::appendNode(T)' with [ T=FeetInches ] linkedlistexample.cpp(11) : see reference to class template instantiation 'LinkedList' being compiled with [ T=FeetInches ] linkedlist.h(48) : error C2227: left of '->value' must point to class/struct/union/generic type linkedlist.h(49) : error C2227: left of '->next' must point to class/struct/union/generic type
-
Help with a Linked List ProgramHere is linked list.h Thanks for all the help by the way. Do you need FeetInches.h also
// A class template for holding a linked list.
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include // For cout and NULL
using namespace std;template
class LinkedList
{
public:
// Declare a structure for the list
struct ListNode
{
T value; // The value in this node
struct ListNode *next; // To point to the next node
};ListNode *head; // List head pointer
public:
// Constructor
LinkedList()
{ head = NULL; }// Destructor
~LinkedList();// Linked list operations
void appendNode(T);
void insertNode(T);
void deleteNode(T);
void displayList() const;
};//**************************************************
// appendNode appends a node containing the value *
// pased into newValue, to the end of the list. *
//**************************************************template
void LinkedList::appendNode(T newValue)
{
ListNode *nodePtr; // To move through the list// Allocate a new node and store newValue there.
newNode = new ListNode;
newNode->value = newValue;
newNode->next = NULL;// If there are no nodes in the list
// make newNode the first node.
if (!head)
head = newNode;
else // Otherwise, insert newNode at end.
{
// Initialize nodePtr to head of list.
nodePtr = head;// Find the last node in the list. while (nodePtr->next) nodePtr = nodePtr->next; // Insert newNode as the last node. nodePtr->next = newNode;
}
}//**************************************************
// displayList shows the value *
// stored in each node of the linked list *
// pointed to by head. *
//**************************************************template
void LinkedList::displayList() const
{
ListNode *nodePtr; // To move through the list//Position nodePtr at the head of the list.
nodePtr = head;// While nodePtr points to a node, traverse
// the list.
while (nodePtr)
{
// Display the value in this node.
cout << nodePtr->value << endl;// Move to the next node. nodePtr = nodePtr->next;
}
}//**************************************************
// The insertNode function inser -
Help with a Linked List ProgramI'm kind of confused I'm not sure if I know what you mean. I looked in my book and it was the same program and the code in the book.
-
Help with a Linked List ProgramI need help with a linked list program, im probably just not doing something write but if any info is available i would greatly appreicate it, here is my code. its suppossed to append a node, insert a node, and delete a node. The output should look like this. Thanks for all help i can get Here are the initial values: 5 feet, 4 inches 6 feet, 8 inches 8 feet, 9 inches Now inserting the value 7 feel 2 inches. Here are the nodes now. 5 feet, 4 inches 6 feet, 8 inches 7 feet, 2 inches 8 feet, 9 inches Now deleting the last node. Here are the nodes left. 5 feet, 4 inches 6 feet, 8 inches 7 feet, 2inches
// This program demonstrates the linked list template. #include "stdafx.h" #include #include "LinkedList.h" #include "FeetInches.h" using namespace std; int main() { // Define a LinkedList object. LinkedList list; // Define some FeetInches objects. FeetInches distance1(5, 4); // 5 feet 4 inches FeetInches distance2(6, 8); // 6 feet 8 inches FeetInches distance3(8, 9); // 8 feet 9 inches // Store the FeetInches objects in the list. list.appendNode(distance1); // 5 feet 4 inches list.appendNode(distance2); // 6 feet 8 inches list.appendNode(distance3); // 8 feet 9 inches // Display the values in the list. cout << "Here are the initial values:\n"; list.displayList(); cout << endl; // Insert another FeetInches object. cout << "Now inserting the value 7 feet 2 inches.\n"; list.insertNode(distance4); // 7 feet 2 inches FeetInches distance4(7, 2); // Display the values in the list. cout << "Here are the nodes now.\n"; list.displayList(); cout << endl; // Delete the last node. cout << "Now deleting the last node.\n"; list.deleteNode(distance4); // Display the values in the list. cout << "Here are the nodes left.\n"; list.displayList(); return 0; }
-
Help With A Password VerifierHi again I was wondering if somebody could help me with this program I cant get it to stop displaying 32 so that I can check if the program actually works. here is my code. Thanks in advance if anyone can help
// LanusPassword.cpp : Defines the entry point for the console application. //Corey Lanus //Program # 10 //Lanus Password //Verifies that the password meets the requirements //November 10, 2008 #include "stdafx.h" #include #include #include using namespace std; int main() { const int size=10; string pass; int length; int caps=0; int num=0; int low=0; cout << "Please enter a 10 character password.\n"; cout << "You must make sure your password has at\n"; cout << "least two uppercase and at least one\n"; cout << "lowercase letter and atleast 1 number.\n"; cin >> pass; length = sizeof(pass); cout << length <<endl; while (length != 10) { cout << "You can only enter 10 characters. Please type again.\n"; cin >> pass; length = sizeof(pass); } for (int cnt=0; cnt<size;>{ cout << pass[cnt] << " "; } // New line cout << endl; for (int i=0; i<size;>{ cin >> pass[i]; if (isdigit(pass[i])) num=num+1; if (isupper(pass[i])) caps=caps+1; if (islower(pass[i])) low=low+1; } while (caps<2 || low < 1 || num < 1) { num=0; caps=0; low=0; cout << "You must make sure your password has at\n"; cout << "least two uppercase and at least one\n"; cout << "lowercase letter and atleast 1 number.\n"; cin >> pass; for (int i=0; i<size;>{ cin >> pass[i]; if (isdigit(pass[i])) num=num+1; if (isupper(pass[i])) caps=caps+1; if (islower(pass[i])) low=low+1; } } cout << "Your password: " << pass << ", is good and excepted.\n"; return 0; }
-
I need help figuring this out pleasethanks I cant believe I missed something so small
-
I need help figuring this out pleaseI was wondering if someone could look at my code and tell me why when i try to get the average of the array it wont give me the average. It compiles, the only problem is the sum and average are the same. here is my code // LanusArrays.cpp : Defines the entry point for the console application. // Corey Lanus // Test 2 Part 2 // Lanus Arrays // Does a lot of things dealing with arrays. // October 16, 2006 #include "stdafx.h" #include #include using namespace std; int main() { const int ARRAY_SIZE = 20; int numbers[ARRAY_SIZE]; int count; ifstream inputFile; inputFile.open("numbers.txt"); for (count = 0; count < ARRAY_SIZE; count++) inputFile >> numbers[count]; inputFile.close(); int total = 0; for (int count = 0; count < ARRAY_SIZE; count++) total += numbers[count]; cout << "The sum of the numbers is: "<< total << endl; cout << endl; double total2 = 0; double average; for (int count = 0; count < ARRAY_SIZE; count++) total2 += numbers[count]; average = total2 / ARRAY_SIZE; cout << "The average of the numbers is: "<< total2 << endl; cout << endl; int highest; highest = numbers[0]; for (count = 1; count < ARRAY_SIZE; count++) { if (numbers[count] > highest) highest = numbers[count]; } cout << "The highest number is: " << highest << endl; cout << endl; int lowest; lowest = numbers[0]; for (count = 1; count < ARRAY_SIZE; count++) { if (numbers[count] < lowest) lowest = numbers[count]; } cout << "The lowest number is: " << lowest << endl; cout << endl; cout << "The numbers are: "; for (count = 0; count < ARRAY_SIZE; count++) cout << numbers[count] << " "; cout << endl; cout << "The numbers are:\n "; for (count = 0; count < ARRAY_SIZE; count++) cout << numbers[count] << " \n"; cout << endl; return 0; }
-
Help with Arraysits done now I just wanted to know if somebody would show me how to initialize the arrays because my book didnt do a really good job explaining it to me.
-
Help with ArraysHello again everyone. I appreciate the helped that I received last time but I need help again on my array programs. I was wondering if some one could tell me how to set up my arrays for the following programs I would greatly appreciate it. Here are the instructions: 1. Grade Book Create a New Project called YourLastnameGradeBook. A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores. Test Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D 0-59 F Write a program that uses a two-dimensional array of characters to hold the five student names, a single-dimensional array of five characters to hold the five students’ letter grade, and five singe-dimensional arrays of four doubles to hold each student’s set of test scores. The program should allow the user to enter each student’s name and his or her four test scores. It should then calculate and display each student’s average test score and a letter grade based on the average. Input validation: Do not accept test scores less than 0 or greater than 100. 2. Payroll Create a New Project called YourLastnamePayroll. Write a program that uses the following arrays: · empId: an array of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 · hours: an array of seven integers to hold the number of hours worked by each employee · payRate: an array of seven doubles to hold each employee’s hourly pay rate · wages: an array of seven doubles to hold each employee’s gross wages The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose identification number is stored in element 0 of the empId array. That same employee’s pay rate should be stored in element 0 of the payRate array. The program should display each employee number and ask the user to enter that employee’s hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages. Input Validation: Do not accept negative values for hours or numbers less than 6.00 for pay rate.
-
Help With A Program. I Dont Know Where To Begin. PLZ HELP MEOk, I have to do 3 programs for school and I am completely lost on how to start either of them off. If somebody could help me I would greatly appreciate it. Here is the info about the programs. 1. Population Create a New Project called YourLastnamePopulation. In a population, the birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: · The starting size of a population · The annual birth rate · The annual death rate · The number of years to display Write a function that calculates the size of the population for a year. The formula is N = P + BP + DP Where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate. Input Validation: Do not accept numbers less than 2 for the starting size. Do not accept negative numbers for birth rate or death rate. Do not accept numbers less than 1 for the number of years. 2. Lowest Score Drop Create a New Project called YourLastnameLowestScore. Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: · void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called from main once for each of the five scores to be entered. · void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores. · int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100. 3. Overloaded Hospital Create a New Project called YourLastnameHospital. Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient, the following data should be entered: · The number of days spent in the hospital · The daily rate · Hospital medication charges · Charges for hospital services (lab tests, etc.) The program should ask for the following data if the pati