Question

Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual...

Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual studio 2013

this is my code so far

#include <cstdlib>
#include <list>
#include <iostream>

using namespace std;
struct node
{
   int data;
   node* next;

};

void initialize(node*p);
void insert(int data,int n);
void remove(int b,int pos);
bool empty(node*);
void length();
bool valuein(int c);
int reportvalue(int value);
void ptintlist();
int menu();

int main()
{

   struct node*head=NULL;
   char commands;
   int value;
   int pos = 0;

   cout << "This program responds to commands the user enters to\nmanipulate an ordered list of integers, which is\ninitially empty. In the following commands, k1 is a\nposition in the list, and v is an integer." << endl;
   cout << "e -- Re-initialize the list to be empty.\ni v -- Insert the value v into the list.\nr v -- Remove the value v from the list.\nm -- Is the list empty ? \nl -- Report the length of the list.\np v -- Is the value v present in the list ? \nk k1 -- Report the k1th value in the list.\nw -- Write out the list.\nh -- See this menu.\nq -- Quit." << endl;
   cout << "-->";
  
   cin >> commands;


   do
   {


       switch (commands)
       {
       case 'e':
           initialize(head->next);
       case 'i':
       {cin >> value;
       insert(value, pos);
       pos++;
       }
       case 'r':
       { cin >> value;

       }
       case'k':
       { cin >> value;
      
       if (valuein(head, value) == true)
       {
           cout << "it is" << endl;
       }

       }

       }

       system("pause");
       return 0;
   } while (commands != 'q');
}
bool empty(node*)
{
   node *root;
   if (root->next == NULL)
       return true;
   else
       return false;
}


   void initialize(node*p)
{
  
   node *temp;
   if (p == NULL){
       return;
   }
   temp = p;
   initialize(p->next);
   delete temp;
}
   void insert(int data, int pos)
   {
       node*head = new node;
       node* prev = new node();
       node* curr = new node();
       node* newNode = new node();
       newNode->data = data;

       int tempPos = 0; // Traverses through the list

       curr = head; // Initialize current to head;
       if (head != NULL)
       {
           while (curr->next != NULL && tempPos != pos)
           {
               prev = curr;
               curr = curr->next;
               tempPos++;
           }

       }
   }
   bool valuein(node*head, int x)
   {
       bool judge=false;
       struct node* current = head; // Initialize current
       while (current != NULL)
       {
           if (current->data == x)
               judge=true;
           current = current->next;
       }
       return judge;
   }
The code is not finished yet.. If you find other mistake I made please let me know. Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <cstdlib>
#include <list>
#include <iostream>

using namespace std;
struct node {
    int data;
    node *next;

};

void initialize(node *p);

void insert(int data, int n);

void remove(int b, int pos);

bool empty(node *);

void length();

bool valuein(node *head, int x);

int reportvalue(int value);

void ptintlist();

int menu();

int main() {

    struct node *head = NULL;
    char commands;
    int value;
    int pos = 0;

    cout
            << "This program responds to commands the user enters to
manipulate an ordered list of integers, which is
initially empty. In the following commands, k1 is a
position in the list, and v is an integer."
            << endl;
    cout
            << "e -- Re-initialize the list to be empty.
i v -- Insert the value v into the list.
r v -- Remove the value v from the list.
m -- Is the list empty ? 
l -- Report the length of the list.
p v -- Is the value v present in the list ? 
k k1 -- Report the k1th value in the list.
w -- Write out the list.
h -- See this menu.
q -- Quit."
            << endl;
    cout << "-->";

    cin >> commands;


    do {


        switch (commands) {
            case 'e':
                initialize(head->next);
            case 'i': {
                cin >> value;
                insert(value, pos);
                pos++;
            }
            case 'r': {
                cin >> value;

            }
            case 'k': {
                cin >> value;

                if (valuein(head, value) == true) {
                    cout << "it is" << endl;
                }

            }

        }

        system("pause");
        return 0;
    } while (commands != 'q');
}

bool empty(node *) {
    node *root;
    if (root->next == NULL)
        return true;
    else
        return false;
}


void initialize(node *p) {

    node *temp;
    if (p == NULL) {
        return;
    }
    temp = p;
    initialize(p->next);
    delete temp;
}

void insert(int data, int pos) {
    node *head = new node;
    node *prev = new node();
    node *curr = new node();
    node *newNode = new node();
    newNode->data = data;

    int tempPos = 0; // Traverses through the list

    curr = head; // Initialize current to head;
    if (head != NULL) {
        while (curr->next != NULL && tempPos != pos) {
            prev = curr;
            curr = curr->next;
            tempPos++;
        }

    }
}

bool valuein(node *head, int x) {
    bool judge = false;
    struct node *current = head; // Initialize current
    while (current != NULL) {
        if (current->data == x)
            judge = true;
        current = current->next;
    }
    return judge;
}
Add a comment
Know the answer?
Add Answer to:
Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Requirements: Finish all the functions which have been declared inside the hpp file. Details: st...

    Requirements: Finish all the functions which have been declared inside the hpp file. Details: string toString(void) const Return a visible list using '->' to show the linked relation which is a string like: 1->2->3->4->5->NULL void insert(int position, const int& data) Add an element at the given position: example0: 1->3->4->5->NULL instert(1, 2); 1->2->3->4->5->NULL example1: NULL insert(0, 1) 1->NULL void list::erase(int position) Erase the element at the given position 1->2->3->4->5->NULL erase(0) 2->3->4->5->NULL //main.cpp #include <iostream> #include <string> #include "SimpleList.hpp" using std::cin; using...

  • C++ - I have a doubly linked list, but I haven't been able to get the...

    C++ - I have a doubly linked list, but I haven't been able to get the "reverse list" option in the code to work(It's option #in the menu in the program). I received this guidance for testing: Test 4 cases by entering (in this order) c,a,z,k,l,m This tests empty list, head of list, end of list and middle of list. Then delete (in this order) a,z,l. This tests beginning, end and middle deletes. This exhaustively tests for pointer errors. #include...

  • Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write...

    Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). #include #include using namespace std; typedef int Type; enum Boolean { False = 0, True }; class Item { friend class SLList; public: Type getVal()...

  • (C++) You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class...

    (C++) You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided). The function will first search through the list for the provided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance...

  • I have a C++ code that lets me enter, display and delete a student record. I...

    I have a C++ code that lets me enter, display and delete a student record. I need to implement a function that prints the average grade score of the students I input. Below is my code and a picture of how my code looks right now. #include<iostream> #include<stdlib.h> using namespace std; //Node Declaration struct node {    string name;    string id;    int score;    node *next;   }; //List class class list {        private:        //head...

  • 1) Create a struct called CourseInfo to store info about a course (Include variables for courseNum,...

    1) Create a struct called CourseInfo to store info about a course (Include variables for courseNum, courseName, & grade) 2) Change the type for the 'data' member variable in the node struct to CourseInfo (see #1) and rename it to 'courseData' 3) Modify the createNode function to receive a CourseInfo struct as a parameter. It should also display the address of the new node that is created. Display the address in both hex and decimal form. 4) Modify the display...

  • C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you...

    C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...

  • C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of...

    C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...

  • #include <iostream> using namespace std; struct ListNode { float value; ListNode *next; }; ...

    #include <iostream> using namespace std; struct ListNode { float value; ListNode *next; }; ListNode *head; class LinkedList { public: int insertNode(float num); void deleteNode(float num); void destroyList(); void displayList(); LinkedList(void) {head = NULL;} ~LinkedList(void) {destroyList();} }; int LinkedList::insertNode(float num) { struct ListNode *newNode, *nodePtr = head, *prevNodePtr = NULL; newNode = new ListNode; if(newNode == NULL) { cout << "Error allocating memory for new list member!\n"; return 1; } newNode->value = num; newNode->next = NULL; if(head==NULL) { cout << "List...

  • You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided)....

    You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided). The function will first search through the list for the provided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT