include using namespace std template class ADT T stackRedB

#include<iostream>
using namespace std;

template <class T>
class ADT
{
   T * stackRedBlue ;
int sizeR ;
int sizeB ;
int topR ;
int topB ;
public:
//Meber Functions
//constructor 1
   ADT(int s1, int s2)
   {
       int size = s1+s2;
       stackRedBlue =new T[size];
       //cout<<\"sizeof = \"<<sizeof(stackRedBlue)<<endl;
       sizeR= s1;
       sizeB= s2;
       topR= 0;
       topB= 0;
   }
//constructor 2 // copy constructor
   ADT(ADT &obj)
   {
       sizeR= obj.sizeR;
       sizeB= obj.sizeB;
       topR= obj.topR;
       topB= obj.topB;
       //stackRedBlue =new ADT(sizeR,sizeB]);
      
       stackRedBlue = obj.stackRedBlue;
   }
//destructor
   ~ADT()
   {
       delete stackRedBlue;
   }
   // is the stack full?
bool isFull()
{
   if( (topR == sizeR) && (topB == sizeB))
       return true;
   else
       return false;
}
// is the red stack full?
bool isFullR()
{
   if( topR == sizeR)
       return true;
   else
       return false;
}
// is the blue stack full?
bool isFullB()
{
   if( topB == sizeB)
       return true;
   else
       return false;
}
// is the stack empty?
bool isEmpty()
{
   if( (topB == 0) && (topR == 0))
       return true;
   else
       return false;

}
// is the red stack empty?
bool isEmptyR()
{
   if( (topR == 0))
       return true;
   else
       return false;
}
bool isEmptyB() // is the blue stack empty?
{
   if( (topB == 0))
       return true;
   else
       return false;
}

void popR( T &R ) // pop an element from the red stack
{
   R = stackRedBlue[--topR];
   delete[topR] stackRedBlue;
  
}
void popB( T &B ) // pop an element from the blue stack
{
   --topB;
   int s = sizeR+topB;
   printB();
   B = stackRedBlue[s];
   delete[sizeR+topB] stackRedBlue;
}
void popRB(T &R, T&B) //pop an element from the red stack and an element from the blue stack
{
   --topB;
   int s = topR+topB;
   R = stackRedBlue[--topR];
   delete[topR] stackRedBlue;
   B = stackRedBlue[s];
   delete[sizeR+topB] stackRedBlue;
}
void pushR( T R) // push a double into the red stack
{
   stackRedBlue[topR] = R;
   topR++;
}
void pushB( T B ) // push a double into the blue stack
{
   stackRedBlue[sizeR+topB] = B;
   topB++;
}
void pushRB( T R, T B) // push a double into the rad stack and a double into the blue
{
   stackRedBlue[topR] = R;
   topR++;
   stackRedBlue[sizeR+topB] = B;
   topB++;
}
//stack
void printR() // print the red stack
{
   for(int i= 0 ; i< topR ; i++)
   {
       cout<<stackRedBlue[i]<<endl;
   }
}
void printB() // print the blue stack
{
   for(int i= sizeR ; i<sizeR+topB ; i++)
   {
       cout<<stackRedBlue[i]<<endl;
   }
}
};

int main()
{
   ADT<double> stack1(2,3),stack2(stack1);
   double num;

   stack2.pushR(1);
   stack2.pushR(9);
   stack2.pushB(3);
   stack2.pushB(5);

   stack2.printR();
   stack2.printB();

   stack2.popR(num);
   cout<<\"popR= \"<<num<<endl;

   stack2.popB(num);
   cout<<\"popB= \"<<num<<endl;
}

This is the program and the output is

How I am going to fix this errors to make the program run properly or correctly.

thank you.

compilation info prog.cpp :93:10: error: expected expression delete DtopR] stackRedBlue prog.cpp :102:10: error: expected expression delete sizeR+topBj stackRedBlue prog.cpp :109: 10: error: expected expression delete DtopR] stackRedBlue prog.cpp :111:10: error: expected expression delete sizeR+topBj stackRedBlue 4 errors generated.

Solution

#include<iostream>
using namespace std;
template <class T>
class ADT
{
T * stackRedBlue ;
int sizeR ;
int sizeB ;
int topR ;
int topB ;
public:
//Meber Functions
//constructor 1
ADT(int s1, int s2)
{
int size = s1 + s2;
stackRedBlue = new T[size];
//cout<<\"sizeof = \"<<sizeof(stackRedBlue)<<endl;
sizeR = s1;
sizeB = s2;
topR = 0;
topB = 0;
}
//constructor 2 // copy constructor
ADT(ADT &obj)
{
sizeR = obj.sizeR;
sizeB = obj.sizeB;
topR = obj.topR;
topB = obj.topB;
//stackRedBlue =new ADT(sizeR,sizeB]);

stackRedBlue = obj.stackRedBlue;
}
//destructor
~ADT()
{
delete stackRedBlue;
}
// is the stack full?
bool isFull()
{
if ( (topR == sizeR) && (topB == sizeB))
return true;
else
return false;
}
// is the red stack full?
bool isFullR()
{
if ( topR == sizeR)
return true;
else
return false;
}
// is the blue stack full?
bool isFullB()
{
if ( topB == sizeB)
return true;
else
return false;
}
// is the stack empty?
bool isEmpty()
{
if ( (topB == 0) && (topR == 0))
return true;
else
return false;
}
// is the red stack empty?
bool isEmptyR()
{
if ( (topR == 0))
return true;
else
return false;
}
bool isEmptyB() // is the blue stack empty?
{
if ( (topB == 0))
return true;
else
return false;
}
void popR( T &R ) // pop an element from the red stack
{
R = stackRedBlue[--topR];
delete[topR];

}
void popB( T &B ) // pop an element from the blue stack
{
--topB;
int s = sizeR + topB;
printB();
B = stackRedBlue[s];
delete[sizeR + topB];
}
void popRB(T &R, T&B) //pop an element from the red stack and an element from the blue stack
{
--topB;
int s = topR + topB;
R = stackRedBlue[--topR];
delete[topR] stackRedBlue;
B = stackRedBlue[s];
delete[sizeR + topB];
}
void pushR( T R) // push a double into the red stack
{
stackRedBlue[topR] = R;
topR++;
}
void pushB( T B ) // push a double into the blue stack
{
stackRedBlue[sizeR + topB] = B;
topB++;
}
void pushRB( T R, T B) // push a double into the rad stack and a double into the blue
{
stackRedBlue[topR] = R;
topR++;
stackRedBlue[sizeR + topB] = B;
topB++;
}
//stack
void printR() // print the red stack
{
for (int i = 0 ; i < topR ; i++)
{
cout << stackRedBlue[i] << endl;
}
}
void printB() // print the blue stack
{
for (int i = sizeR ; i < sizeR + topB ; i++)
{
cout << stackRedBlue[i] << endl;
}
}
};
int main()
{
ADT<double> stack1(2, 3), stack2(stack1);
double num;
stack2.pushR(1);
stack2.pushR(9);
stack2.pushB(3);
stack2.pushB(5);
stack2.printR();
stack2.printB();
stack2.popR(num);
cout << \"popR= \" << num << endl;
stack2.popB(num);
cout << \"popB= \" << num << endl;
}

#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me
#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me
#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me
#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me
#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me
#include<iostream> using namespace std; template <class T> class ADT { T * stackRedBlue ; int sizeR ; int sizeB ; int topR ; int topB ; public: //Me

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site