My program is basically reading a list of names from a txt file and inserting them into the queue and I have several options after that.
My problem is for for pressing quit I have to clear the queue and exit the program. I believe it works (if I did it right) after printing the queue or removing a name from the queue.
However, when I remove something and insert another name back, then try to clear it I get a breaking point.
#ifndef _QueueClass_
#define _QueueClass_
#include <cstdlib>
#include <string>
class Qqueue
{
public:
// Constructor
Qqueue(int cap);
// Copy Constructor
Qqueue(const Qqueue& s);
~Qqueue(); //destructor
//assignment operator
voidoperator=(const Qqueue& s);
// The member function enqueue: Precondition: the queue is not full. If the queue is full, this function signals an error.
//add value to the end of the queue
void enqueue(const std::string& s);
// The member function dequeue: Precondition: the queue is not empty. If the queue is empty, this function signals an error.
// Removes and returns the first item in the queue.
std::string dequeue();
// The member function front: Precondition: the queue is not empty.
std::string& getfront() const;
// The member function back: Precondition: the queue is not empty.
std::string& getback() const;
bool IsEmpty() const;
bool IsFull() const;
//printing all the elements in the queue
void print() const;
std::string clearAll();
int size() const;
int getCapacity() const;
//Get the location of DynamicQueue at a specific index
std::string& getQueue(int);
//Returns true if the two queues contain exactly the same element values in the same order. Identical in behavior to the == operator.
bool equals(const Qqueue& q) const;
// Usage: if (q.equals(q2)) ...
private:
int Capacity; // Capacity is the maximum number of items that a queue can hold
std::string* DynamicQueue;
int num; // How many items are stored in the queue
int front;
int back;
};
#endif
#pragma once
Errors
1 2 3 4 5
'Qqueue.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'Qqueue.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
The thread 0x66e8 has exited with code 0 (0x0).
Critical error detected c0000374
Qqueue.exe has triggered a breakpoint.
When I remove say 5 names and add in a new name, it works fine.
But when I remove 5 names and then add back one of those names removed it gets this.
The debugger should tell you exactly where it detects the problem, and you should be able to view the values of the variables at the time of the crash.
Without a complete program it is difficult to determine the cause of a crash.