Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Following code that is in C++ I get errors that say Too many arguments to function call, expected 0, have 1 or Too

In the Following code that is in C++ I get errors that say "Too many arguments to function call, expected 0, have 1" or "Too few arguments to function call, single argument 'element' was not specified" in the main.cpp when trying to enqueue and dequeue.

I can't for the life of me figure out why its giving me errors.

Thank you for your time, the code will be down below

Main.cpp

// Stack-Queue-Vector.cpp : This file contains the 'main' function. Program execution begins and ends there.

//

#include "StackV.h"

#include "QueueV.h"

#include

#include

using namespace std;

int main()

{

cout << "StackV and Queue V test program" << endl;

// Test StackV

// Create object with new

StackV* stack = new StackV();

cout << boolalpha << stack->empty() << endl;

stack->push(10);

stack->push(20);

stack->push(30);

stack->push(40);

cout << stack->top() << endl;

stack->push(50);

stack->push(60);

stack->push(70);

cout << stack->top() << endl;

stack->pop();

cout << stack->top() << endl;

stack->pop();

cout << stack->top() << endl;

stack->pop();

cout << stack->top() << endl;

// Delete object

delete stack;

// Create object with new

QueueV* queue = new QueueV();

queue->enqueue(10);

queue->enqueue(20);

queue->enqueue(30);

queue->enqueue(40);

cout << queue->front() << endl;

queue->enqueue(50);

queue->enqueue(60);

queue->enqueue(70);

cout << queue->front() << endl;

queue->dequeue();

cout << queue->front() << endl;

queue->dequeue();

cout << queue->front() << endl;

queue->dequeue();

cout << queue->front() << endl;

queue->display();

cout << std::boolalpha << queue->empty() << endl;

// Delete object

delete queue;

return 0;

}

StackV.Cpp

#include "StackV.h"

#include

using namespace std;

//constructor

StackV::StackV()

{

//default constructor

}

//--- Definition of empty()

//if vector is empty or not

bool StackV::empty()

{

//check to see if vector is empty to return that value

if(v.size()>0)

return false;

return (true);

}

//push into stack

void StackV::push(int value)

{

v.push_back(value);

// Figure out how to push a value onto the vector

cout<<" Pushed value :"<

}

//push into stack

void StackV::pop()

{

//v.pop_back();

cout<<" Poped value, : "<

v.pop_back();

//cout<

//Figure out how to pop an element off

}

//get top of the element

int StackV::top()

{

// How to view the top of the stack using vector"

if(v.size()>0)

return v.back();

return (-1);

}

StackV.h

/*-- Stack.h ---------------------------------------------------

This header file defines a Stack data type.

Basic operations:

constructor:Constructs an empty stack

empty:Checks if a stack is empty

push: Modifies a stack by adding a value at the top

top:Retrieves the top stack value; leaves stack unchanged

pop:Modifies stack by removing the value at the top

display:Displays all the stack elements

Class Invariant:

1. The stack elements (if any) are stored in positions

0, 1, . . ., myTop of myArray.

2. -1 <= myTop < STACK_CAPACITY

--------------------------------------------------------------*/

#include

#include

using namespace std;

#ifndef STACK

#define STACK

class StackV

{

public:

StackV();

bool empty();

void push(int element);

void pop();

int top();

private:

vector<int> v;

}; // end of class declaration

#endif

Queue.cpp

#include "QueueV.h"

#include

using namespace std;

//constructor

QueueV::QueueV()

{

//default constructor

}

//--- Definition of empty()

//if vector is empty or not

bool QueueV::empty()

{

//check to see if vector is empty to return that value

if(v.size()>0)

return false;

return (true);

}

//push into queue

void QueueV::dequeue(int element)

{

// push a value onto the vector

v.push_back(element);

cout << " Pushed value :" << element << endl;

}

//push into queue

void QueueV::enqueue()

{

//v.pop_back();

cout << " Poped value : " << v.front();

//vector < int v;

for(int i=0; i

{

v[i]=v[i+1];

}

//cout<

//Figure out how to pop an element off

}

//get top of the element

int QueueV::front()

{

// How to view the top of the stack using vector"

if(v.size() > 0)

return v.front();

return (-1);

}

Queue.h

#include

#include

using namespace std;

#ifndef QUEUE

#define QUEUE

//class queue

class QueueV

{

public:

//constructor

QueueV();

//queue is empty

bool empty();

//push into queue

void dequeue(int element);

//pop top element

void enqueue();

//get top element

int front();

private:

vector<int> v;

};

// end of class declaration

#endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

=+2. When to use ML / when not to use ML?

Answered: 1 week ago