We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.
class QueueElement {
public:
virtual ~QueueElement(){}
double data;
QueueElement *next;
void setData(double d)
{
data=d;
}
double getData()
{
return data;
}
QueueElement const *getNext() const
{
return next;
}
};
/// no further inhertince to QueueElementint and so on done.
#include <iostream>
using namespace std;
#define SIZE 20
#include "abstract.h"
class QueueClass{
private:
int queue[SIZE];
int head, tail;
int num;
public:
QueueClass();
void qu(QueueElement* newElement);
int dequ();
int size();
int isEmpty();
};
QueueClass::QueueClass()
{
head = tail = 0;
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = num;
}
int QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
int QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
///queuet.h
#ifndef QUEUET_H
#define QUEUET_H
#include <iostream>
using namespace std;
#define SIZE 20
template <typename T>
class QueueClass
{
T queue[SIZE];
T head, tail;
public:
QueueClass(T, T);
~QueueClass(){};
void qu(T num);
T dequ();
T size();
T isEmpty();
};
#endif
////qeuet.cc
#include "QUEUET.H"
template <typename T>
QueueClass<T>::QueueClass (T a, T b) { //expected ; befor < token
head = a;
tail = b;
}
template <typename T>
void QueueClass<T>::qu(T num) //init declarator before < token //expected ; befor < token
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = num;
}
template <typename T>
T QueueClass<T>::dequ() //init declarator before < token //expected ; befor < token
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
template <typename T>
T QueueClass<T>::size()
{ //init declarator before < token //expected ; befor < token
T j=0;
for (; j<tail; j++){
}
return j;
}
template <typename T>
T QueueClass<T>::isEmpty()
{ //init declarator before < token //expected ; befor < token
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
/// main.cc
#include <iostream>
#include "queuet.cc"
using namespace std ;
int main()
{
QueueClass<int> queue1 (1,1); ////expected ; before int //QueueClass undeclared //expect primary expression before int
cout<<"If 1, Queue is Empty, else 0 aka Queue is not empty. Result: " <<queue1.isEmpty()<<endl;
int i;
for(i=1; i <=10; i++) {
queue1.qu(i); // queue1 undecleared, first use
}
cout<<"If 1, Queue is Empty, else 0 aka Queue is not empty. Result: " <<queue1.isEmpty()<<endl;
cout<< queue1.size() <<" test" <<endl;
for(i=1; i <=10; i++)
cout << "Dequeue 1: " << queue1.dequ() << endl;
return 0;
}
#include <iostream>
using namespace std;
class QueueElement {
private:
QueueElement *next;
double data;
QueueElement(int d){
data=d;
next=0L;
}
virtual ~QueueElement(){
}
virtual setData( d) =0;
virtual QueueElement::getData() =0;
virtual QueueElement::*getNext() =0;
};
#include <iostream>
using namespace std;
class QueueElement {
private:
QueueElement *next;
double data;
QueueElement(int d){
data=d;
next=0L;
}
virtual ~QueueElement(){
}
virtual setData( d) =0;
virtual getData() =0;
virtual *getNext() =0;
};
class QueueElementInt : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
int getData(){
return data;
}
QueueElementInt *getNext(){
return next;
}
};
class QueueElementFloat : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
float getData(){
return data;
}
QueueElementInt *getNext(){
return next;
}
};
#include <iostream>
using namespace std;
class QueueElement {
private:
double data;
public:
QueueElement(int d){
data=d;
next=0L;
}
virtual ~QueueElement(){
}
virtual voidsetData( d) =0;
virtual int getData() =0;
// virtual *getNext() =0;
};
class QueueElementInt : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
int getData(){
return data;
}
};
class QueueElementFloat : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
float getData(){
return data;
}
};
#include "QUEUET.H"
template <typename T>
QueueClass<T>::QueueClass (T a, T b) {
tail = b;
head = a;
}
template <typename T>
void QueueClass<T>::qu(T num)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = num;
}
template <typename T>
T QueueClass<T>::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
template <typename T>
T QueueClass<T>::size()
{
T j=0;
for (; j<tail; j++){
}
return j;
}
template <typename T>
T QueueClass<T>::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
#include <iostream>
using namespace std;
class QueueElement {
private:
double data;
public:
QueueElement(int d){
data=d;
}
virtual ~QueueElement(){
}
virtual void set Data( d) =0;
virtual double getData() =0;
};
class QueueElementFloat : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
double getData(){
return data;
}
};
class QueueElementDouble : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void setData(d){
data=d;
}
double getData(){
return data;
}
};
#include <iostream>
using namespace std;
class QueueElement {
private:
public:
QueueElement(){
}
virtual ~QueueElement(){
}
virtual void print() =0;
};
class QueueElementFloat : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void print(){
std::cout<<"I'm QueueElementFloat" <<std::endl;
}
};
class QueueElementIny : public QueueElement
{
public:
QueueElementInt();
~QueueElementInt();
void print(){
std::cout<<"I'm QueueElementInt" <<std::endl;
}
};
#include <iostream>
using namespace std;
#define SIZE 20
#include "abstract.h" //That should be my Base class
class QueueClass{
private:
int queue[SIZE];
int head, tail;
int num;
public:
QueueClass();
void qu(QueueElement* newElement);
int dequ();
int size();
int isEmpty();
};
QueueClass::QueueClass()
{
head = tail = 0;
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = num;
}
int QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
int QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
#include "QUEUET.H"
QueueClass::QueueClass (QueueElement* a, QueueElement* b) {
head = a;
tail = b;
}
void QueueClass::qu(QueueElement* num)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = num;
}
QueueElement QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
boolean QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return true;
}
else return false;
}
#ifndef QUEUE_H
#define QUEUE_H
#include <iostream>
using namespace std;
#define SIZE 20
class QueueClass
{
QueueElement queue[SIZE];
QueueElement head, tail;
public:
QueueClass();
~QueueClass(){};
void qu(QueueElement* num);
void dequ();
int size();
boolean isEmpty();
};
#endif
#ifndef QUEUE_H
#define QUEUE_H
#define SIZE 20
class QueueClass
{
QueueElement* queue[SIZE];
QueueElement* head, tail;
public:
QueueClass();
~QueueClass(){};
void qu(QueueElement* num);
void dequ();
int size();
bool isEmpty();
};
#endif
#include <iostream>
#define SIZE 20
#include "abstract.h"
class QueueClass
{
QueueElement* queue[SIZE];
QueueElement* head, tail;
public:
QueueClass();
~QueueClass(){};
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
};
QueueClass::QueueClass()
{
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
std::cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE) tail = 0;
queue[tail] = newElement;
}
QueueElement* QueueClass::dequ()
{
if(head == tail) {
std::cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
std::cout << "Queue is empty\n";
return 1;
}
else return 0;
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
int queue[SIZE];
int head, tail;
public:
QueueClass(int, int);
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::~QueueClass () {}
QueueClass::QueueClass (int a, int b) {
head = a;
tail = b;
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE){ tail = 0;
queue[tail] = QueueElement*;//expected primary expression before '*' token //expected primary expression before ';' token
}
}
QueueElement* QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0; //invalid conversion from 'int' to 'QueueElement'
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool QueueClass::isFull(){
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return true;
}
else{
return false;
}
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
int queue[SIZE];
int head, tail;
public:
QueueClass(int, int);
~QueueClass();
void qu(QueueElement* newElement);
int dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::~QueueClass () {}
QueueClass::QueueClass (int a, int b) {
head = a;
tail = b;
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE){ tail = 0;
queue[tail] = newElement;//invalid conversion from QueueElement* to int
}
}
int QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0; //invalid conversion from 'int' to 'QueueElement'
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool QueueClass::isFull(){
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return true;
}
else{
return false;
}
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
QueueElement* queue[SIZE];
int head, tail;
public:
QueueClass(int, int);
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::~QueueClass () {}
QueueClass::QueueClass (int a, int b) {
head = a;
tail = b;
}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE){ tail = 0;
queue[tail] = newElement;//invalid conversion from QueueElement* to int
}
}
QueueElement* QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool QueueClass::isFull(){
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return true;
}
else{
return false;
}
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
QueueElement* queue[SIZE];
int head, tail;
public:
// QueueClass(int, int);
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::~QueueClass () {}
//QueueClass::QueueClass (int a, int b) {
// head = a;
// tail = b;
//
//}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE){ tail = 0;
queue[tail] = newElement;//invalid conversion from QueueElement* to int
}
}
QueueElement* QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool QueueClass::isFull(){
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return true;
}
else{
return false;
}
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
QueueElement* queue[SIZE];
int head, tail;
public:
QueueClass();
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::QueueClass(): head(-1) , tail(-1){}
QueueClass::~QueueClass () {}
void QueueClass::qu(QueueElement* newElement)
{
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return;
}
tail++;
if(tail==SIZE){ tail = 0;
queue[tail] = newElement;//invalid conversion from QueueElement* to int
}
}
QueueElement* QueueClass::dequ()
{
if(head == tail) {
cout << "Queue is empty\n";
return 0;
}
head++;
if(head==SIZE) head = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool QueueClass::isFull(){
if(tail+1==head || (tail+1==SIZE && !head)) {
cout << "Queue is full\n";
return true;
}
else{
return false;
}
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
QueueElement* queue[SIZE];
int head, tail;
public:
QueueClass();
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
bool isFull();
};
QueueClass::QueueClass(): head(-1) , tail(-1){} // -1 is not correct init list is fine
QueueClass::~QueueClass () {}
void QueueClass::qu(QueueElement* newElement) //ok
{
if(head+1==tail || (head+1==SIZE && !tail)) { //ok //head is tail before and tail is head before
cout << "Queue is full\n";
return;
}
head++;
if(head==SIZE){ head = 0;
queue[head] = newElement;//invalid conversion from QueueElement* to int
}
}
QueueElement* QueueClass::dequ()
{
if(tail == head) {
cout << "Queue is empty\n";
return 0;
}
tail++;
if(tail==SIZE) tail = 0;
return queue[head];
}
int QueueClass::size()
{
int j=0;
for (; j<tail; j++){
}
return j;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
//bool QueueClass::isFull(){
//
// if(tail+1==head || (tail+1==SIZE && !head)) {
// cout << "Queue is full\n";
// return true;
// }
// else{
// return false;
// }
}
#include <iostream>
using namespace std;
#define SIZE 20
#include "queueel.h"
class QueueClass {
QueueElement* queue[SIZE];
int head, tail;
public:
QueueClass();
~QueueClass();
void qu(QueueElement* newElement);
QueueElement* dequ();
int size();
bool isEmpty();
};
QueueClass::QueueClass(): head(-1) , tail(-1){} // -1 is not correct init list is fine
QueueClass::~QueueClass () {}
void QueueClass::qu(QueueElement* newElement) //ok
{
if(isEmpty()){
queue[head]=queue[tail]=newElement;
}
else{
tail++;
queue[tail] = newElement;
}
}
QueueElement* QueueClass::dequ()
{
if (isEmpty()) {return NULL;}
else
{
tail--;
return queue[tail]; //or head?
}
}
int QueueClass::size()
{
if(isEmpty()) {return 0;}
else
return tail;
}
bool QueueClass::isEmpty()
{
if(head == tail) {
cout << "Queue is empty\n";
return 1;
}
else return 0;
}
bool isEmpty()
{
if (head>tail){
head-tail ==1;
std::cout<<"true" <<std::endl;
return 1;
}
else if(head<tail){
tail-head==-1;
std::cout<<"true" <<std::endl;
return 1;
}
else if(head==0, tail==0){
std::cout<<"true" <<std::endl;
return 1;
}
else{
std::cout<<"false" <<std::endl;
return 0;
}
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Getting IP address | 8 | 89 | |
Socket Programming (Unix) | 8 | 142 | |
Safe conversion? | 4 | 72 | |
HTTPSendRequest with WinINet delays on first call | 11 | 35 |
Join the community of 500,000 technology professionals and ask your questions.