aaronmk2 Junior Poster in Training

When I read in this file it reads in the entire line.
[CODE]
string filename ="f:\date.txt";

        FileStream f = new FileStream(filename, FileMode.Open);
        StreamReader stream = new StreamReader(f);

        int line;

        int[] array = new int[15]; 
        for (int i = 0; i < 15; i++)
        {

            line = stream.Read();    // header line
            Console.WriteLine(line);

        }

[/CODE]

The line it reads in from the file is 001 10:00 ON
How would I read the line if so 001 is as int, 10:00 is a string, and ON is a string?

aaronmk2 Junior Poster in Training

I am writing a program using vector and am wondering if my destructor is correct, or do I need to add another line. The clear, clears all the elements in the vector, but do I need to add another line to delete the vector, and if I do what line should I add. I tried delete empID and varations of that and all I got was error messages.
[CODE]
heap::~heap(){
empID.clear();
}[/CODE]

empID is the name of the vector and it is ints.

aaronmk2 Junior Poster in Training

Can someone explain to me what is going on in this code. I am leaving comments by each line.
[CODE]
void qs::quicksort(int set[], int start, int end){
stacks;//starts a stack to hold them elements
s.push(start);//why push two elements, why not one so the while loop works
s.push(end);
while (!s.empty()) { //does it need an infinity loop before it so it works more then once?
s.pop();
s.pop();
if (end<=1) continue;//don't understand this line
int i=partition(set, start, end);//I understand this.
if (i-start>end-i) {
s.push(start);//pushing in the first element
s.push(i-1);//the one before the partition
s.push(i+1);//the one after the partition
s.push(end);}//the last element
if (end-i<=i-start) {//ignore the rest
s.push(start);
s.push(i-1);
}
}
}
[/CODE]

aaronmk2 Junior Poster in Training

I am having trouble with my quicksort. When I run my program it sorts them once( the lower half of the numbers are on one side, the higher half on the other). How can I get it to sort again without using a recursive function.
[CODE]
void qs::quicksort(int set[], int start, int end){
stacks;
s.push(start);
s.push(end);
while (!s.empty()) {
s.pop();
s.pop();
if (end<=1) continue;
int i=partition(set, start, end);
if (i-start>end-i) {
s.push(start);
s.push(i-1);
s.push(i+1);
s.push(end);}
if (end-i<=i-start) {
s.push(start);
s.push(i-1);
}
}
}[/CODE]

aaronmk2 Junior Poster in Training

Can someone explain and give an example of how double hashing works. I understand linear, quadratic, and chain.

aaronmk2 Junior Poster in Training

My profesor added this line of code to a bubble sort saying that it made it more efficient by tracking the last swap. I don't understand how this would work
[CODE]
void bubble_sort(int a[], int n){
while (0<n-1) {
int last =0;
for (int i=0; i<n-1; i++) {
if (a[i]>a[i+1]) {
swap(a[i],a[i+1])
last=i;//this line tracks the last swap, but how would it stop the program once it is sorted?
}
}
}
}
[/CODE]

aaronmk2 Junior Poster in Training

I am having trouble figuring out what the recursive function does in the insert sort. Wouldn't the recursive line block the rest of the code from working. I am just looking for a quick explanation.
[CODE]
void insertion_sort-recur(int a[], int n){
if(n<=1)
return;
insertion-sort_recur(a, n-1);//how does this line work
temp=a[n-1];
for(int i=n-2; i>=0 && temp<a[i];i--){
a[i+1]=a[i];
} a[i+1]=temp;

}
}[/CODE]

Good thing its not due till friday. If you want to get the most out of this sight, you need to post a small question and be 80% of the way done;)

aaronmk2 Junior Poster in Training

I an trying to find the height in a binary search tree. I figured out how to count the leaves going directly left and directly right, but cannot figure out how to get he leaves in the middle.
[CODE]
int BST::height(){
int tall =0;
int tall1=0;
BinNodePtr ptr=myRoot;
if (ptr->left =='\0' && ptr->right =='\0')
return tall;//up to this part I know is correct.
else {
while (ptr->left) {
ptr=ptr->left;
tall++;
}
ptr=myRoot;
while (ptr->right) {
ptr=ptr->right;
tall1++;
}
}
if (tall>tall1)
return tall;
else
return tall1;
[/CODE]

Thanks, my program no longer leaks memory. Do you have any ideas of what I could have done to my original destructor to make it work?

aaronmk2 Junior Poster in Training

My program runs, but I am getting this message which I am fairly sure means that I have a memory leak and it is coming from my destructor.
Assignment2(779) malloc: *** error for object 0x100100120: pointer being freed was not allocated
I don't know what I am doing wrong. Since it is a binary search tree I figured while not empty go left if you can't go left go right, if you can't go right, delete. Any tips would be great.
[CODE]
BST::~BST()
{
BinNodePtr parent = 0, temp = myRoot;
while(!empty()){
while(temp->left!='\0'){
parent = temp;
temp = temp->left;
}
while (temp->right!='\0'){
parent = temp;
temp = temp->right;
}
delete temp;
}
}[/CODE]

aaronmk2 Junior Poster in Training

I am pretty sure that the answer for this is n^3, because the 3rd for loop is executed n times and the middle is executed n+4 times and the top one is executed n times. I understand how to use sigma notation for the bottom and top for loop because is uses n, but what do I do different for the middle one because it uses j instead of n
[CODE]
for (int j = 4; j < n; ++j) {
cin >> val; }
for (int i = 0; i < j; ++i) {
b = b * val;}
for (int k = 0; k < n; ++k)
c = b + c;}
}[/CODE]

aaronmk2 Junior Poster in Training

I am multiplying two polynomials and cannot figure out how to add the exponents. The loop is to multiply the coefficients and degree is for the total degrees used in the polynomial. But I can't figure out what I should use to add the exponents.
[CODE]
Poly Poly:: operator*(const Poly& p)
{

Poly temp;//declare to hold new result
for (int i=0; i<degree+1; i++){
    temp.coefs[i] =coefs[i] * p.coefs[i];
}
    temp.degree = degree;
return temp;

}
[/CODE]
Here is the entire code
[CODE]

include

using namespace std;

ifndef _POLY_H
define _POLY_H

const int CAPACITY =100;

class Poly {
public:
Poly();
~Poly();
void display(ostream & out)const;
void input(istream &in);
int evaluate(int x);
Poly operator+(const Poly &p);
Poly operator *(const Poly &p);
private:
int degree;
int coefs[CAPACITY];
};
ostream & operator<<(ostream & out, const Poly & p);
istream & operator>>(istream &in, Poly &p);

endif
include "Poly.h"
include
include

using namespace std;

Poly::Poly():degree(0){
for (int i=0; i<CAPACITY; i++) {
coefs[i]=NULL;
}
}
Poly::~Poly(){
}
void Poly::display(ostream &out)const{
for (int i=0; i<degree; i++) {
out<<coefs[i]<<"x^"<<i<<" + ";
}
for (int i=degree; i<degree+1; i++) {
out<<coefs[i]<<"x^"<<i;
}

}
void Poly::input(istream & in){
in>>degree;
for (int i=0; i<degree+1; i++) {
in>>coefs[i];
}
}
int Poly::evaluate(int x){
int sum=0;
double xd = static_cast(x);
double totalPow;
for (int i=0; i<degree+1; i++) {
totalPow =pow(xd, i);
sum+=(coefs[i]*totalPow);
}
return sum;

}
Poly Poly:: operator+(const Poly& p)
{
Poly temp;//declare to hold new result
if (degree < p.degree) {
degree=p.degree;
}
for (int i=0; i<degree+1; i++){
temp.coefs[i] =coefs[i] + ...

aaronmk2 Junior Poster in Training

I am using an overloading operator to add two polynomials. I have gotten it to work, but I am wondering if I can improve on my if statement by not changing the value of degree for the rest of my program. The if statement is used if the second polynomial is larger then the first so the program will use the larger polynomial for the loop. When I do this it changes degree(the smaller polynomial length) to p.degree(the larger one) for the rest of the program. I am pretty sure this is not good coding. Any tips?

[CODE]
Poly Poly:: operator+(const Poly& p)
{

Poly temp;//declare to hold new result
if (degree < p.degree) {
    degree=p.degree;//is there another way to do this?
}
for (int i=0; i<degree+1; i++){
temp.coefs[i] =coefs[i] + p.coefs[i];
}
temp.degree = degree;
return temp;

}[/CODE]

Here is the entire program
[CODE]

include

using namespace std;

ifndef _POLY_H
define _POLY_H

const int CAPACITY =100;

class Poly {
public:
Poly();
~Poly();
void display(ostream & out)const;
void input(istream &in);
int evaluate(int x);
Poly operator+(const Poly &p);
Poly operator *(const Poly &p);
private:
int degree;
int coefs[CAPACITY];
};
ostream & operator<<(ostream & out, const Poly & p);
istream & operator>>(istream &in, Poly &p);

endif
include "Poly.h"
include
include

using namespace std;

Poly::Poly():degree(0){
for (int i=0; i<CAPACITY; i++) {
coefs[i]=NULL;
}
}
Poly::~Poly(){
}
void Poly::display(ostream &out)const{
for (int i=0; i<degree; i++) {
out<<coefs[i]<<"x^"<<i<<" + ";
}
for (int i=degree; i<degree+1; i++) {
out<<coefs[i]<<"x^"<<i;
}

}
void Poly::input(istream ...

aaronmk2 Junior Poster in Training

I am writing a program where the user inputs two polynomials, then the program adds them, multiplies them, and evaluates one of them. I am having two problems. First, I can't think of how to add the exponents in the overloaded method for *. Second when the two polynomials multiply it returns 0 after the shorter polynomial ends.

[CODE]

include

using namespace std;

ifndef _POLY_H
define _POLY_H

const int CAPACITY =100;

class Poly {
public:
Poly();
~Poly();
void display(ostream & out)const;
void input(istream &in);
int evaluate(int x);
Poly operator+(const Poly &p);
Poly operator *(const Poly &p);
private:
int degree;
int coefs[CAPACITY];
};
ostream & operator<<(ostream & out, const Poly & p);
istream & operator>>(istream &in, Poly &p);

endif
include "Poly.h"
include
include

using namespace std;

Poly::Poly():degree(0){
for (int i=0; i<CAPACITY; i++) {
coefs[i]=NULL;
}
}
Poly::~Poly(){
}
void Poly::display(ostream &out)const{
for (int i=0; i<degree; i++) {
out<<coefs[i]<<"x^"<<i<<" + ";
}
for (int i=degree; i<degree+1; i++) {
out<<coefs[i]<<"x^"<<i;
}

}
void Poly::input(istream & in){
in>>degree;
for (int i=0; i<degree+1; i++) {
in>>coefs[i];
}
}
int Poly::evaluate(int x){
int sum=0;
double xd = static_cast(x);
double totalPow;
for (int i=0; i<degree+1; i++) {
totalPow =pow(xd, i);
sum+=(coefs[i]*totalPow);
}
return sum;

}
Poly Poly:: operator+(const Poly& p)
{
Poly temp;//declare to hold new result
if (degree < p.degree) {
degree=p.degree;
}
for (int i=0; i<degree+1; i++){
temp.coefs[i] =coefs[i] + p.coefs[i];
}
temp.degree = degree;
return temp;

}
Poly Poly:: operator*(const Poly& p)
{

Poly temp;//declare to hold new result
for (int ...

But when I changed degree to 7 I still got the same result

aaronmk2 Junior Poster in Training

I am trying add two polynomials by overloading the + operator. When I run the program it only adds the first coeficients. I cannot figure out why it is only returning the first coeficient.
[CODE]
//header file

include

using namespace std;

ifndef _POLY_H
define _POLY_H

const int CAPACITY =100;

class Poly {
public:
Poly();
~Poly();
void display(ostream & out)const;
void input(istream &in);
int evaluate(int x);
Poly operator+(const Poly &p);
Poly operator *(const Poly &p);
private:
int degree;
int coefs[CAPACITY];
};
ostream & operator<<(ostream & out, const Poly & p);
istream & operator>>(istream &in, Poly &p);

endif

//class file

include "Poly.h"
include
include

using namespace std;

Poly::Poly():degree(0){
}
Poly::~Poly(){
}
void Poly::display(ostream &out)const{
for (int i=0; i<degree; i++) {
out<<coefs[i]<<"x^"<<i<<" + ";
}
for (int i=degree; i<degree+1; i++) {
out<<coefs[i]<<"x^"<<i;
}

}
void Poly::input(istream & in){
in>>degree;
for (int i=0; i<degree+1; i++) {
in>>coefs[i];
}
}
int Poly::evaluate(int x){
int sum=0;
double xd = static_cast(x);
double totalPow;
for (int i=0; i<degree+1; i++) {
totalPow =pow(xd, i);
sum+=(coefs[i]*totalPow);
}
return sum;

}
Poly Poly:: operator+(const Poly& p)//this is where I am having trouble
{
Poly temp;//declare to hold new result
for (int i=0; i<degree; i++){
temp.coefs[i] =coefs[i] + p.coefs[i];
}

return temp;//only returns first coefficint

}
Poly Poly:: operator(const Poly& p)
{
Poly temp;//declare to hold new result
temp.degree =degree
p.degree;
temp.degree=this->degree*p.degree;
return temp;
}
istream & operator>>(istream & in, Poly &p){
p.input(in);
return in;
}
ostream &operator<<(ostream &out, const Poly &p){
p.display(out);
return out;
}

//client file ...

aaronmk2 Junior Poster in Training

I am having trouble with the evaluate class. An error message is coming back for the pow(x, degree). I have included the cmath library and have cast x and degree into double. Any hints or tips would be greatly appreciated. I have tested the program without the pow(x, degree) and it works.

int Poly::evaluate(int x){
    int sum=0;
    static_cast<double>(x);
    static_cast<double>(degree);
    for (int i=0; i<degree; i++) {
        sum+=coefs[i]*(pow(x, degree));//here is where I am getting the error
    }
    return sum;

}
aaronmk2 Junior Poster in Training

When I compile I get this error message for istream
error: no match for 'operator>>' in 'in >> ((Rock*)this)->Rock::myName'
I did not include the program with main because I have not used it yet.

[CODE]

ifndef ROCK_H
define ROCK_H
include

using namespace std;
enum RockName {BASALT, DOLOMITE, GRANITE, GYPSUM, LIMESTONE, MARBLE, OBSIDIAN,
QUARZITE, SANDSTONE, SHALE, ROCK_OVERFLOW};

class Rock
{
public:
Rock();
Rock(RockName rockName);
void display(ostream & out) const;
void read(istream & in);
private:
RockName myName;
};
ostream & operator <<(ostream & out, const Rock &t);
istream & operator >>(istream & in, Rock &t);

endif
include

using namespace std;

include "Rock.h"

Rock::Rock():myName(BASALT)
{
}
Rock::Rock(RockName rockName)
{
myName= rockName;
}
void Rock::display(ostream & out) const
{
out<<myName;
}
void Rock::read(istream &in)
{
in>>myName;//this is where I am getting the error
}
ostream & operator<<(ostream & out, const Rock & t)
{
t.display(out);
return out;
}
istream & operator>>(istream & in, Rock & t)
{
t.read(in);
return in;
}

[/CODE]

aaronmk2 Junior Poster in Training

I am getting this error message
error: expected primary-expression before 'enum'
I can't figure it out.

[CODE]

ifndef ROCK_H
define ROCK_H

enum RockName {BASALT, DOLOMITE, GRANITE, GYPSUM, LIMESTONE, MARBLE, OBSIDIAN,
QUARZITE, SANDSTONE, SHALE, ROCK_OVERFLOW};

class Rock
{
public:
Rock()
{myName = BASALT;}
Rock(enum RockName)
{myName= RockName;}//here is where I am getting the error

private:
RockName myName;

};

endif[/CODE]
aaronmk2 Junior Poster in Training

I'm getting error: no match for 'operator>>' in 'std::cin >> aTable[i][j]' for
[CODE]

include

using namespace std;

const int NUM_ROWS=15;
const int NUM_COLUMNS=15;
typedef int TwoDimArray[NUM_ROWS][NUM_COLUMNS];

void printTable(int rows, int cols, TwoDimArray aTable);

int main () {
int rows, columns;
TwoDimArray aTable[rows][columns];
cout<<"Enter rows and columns";
cin>>rows>>columns;
for (int i=0; i<rows; i++) {
for (int j=0; j<columns; j++)
cin>>aTable[i][j];//this is the line I am getting this error for.
}
return 0;
}
[/CODE]
I can't figure out why I am getting this error.

aaronmk2 Junior Poster in Training

I want to center this.
[CODE]cout<<a<<" "<<"+ x = "<<b<<endl;[/CODE]
a and b are both int. How would I go about this. Most of the information I found on the web is about centering strings, I tried the code but did not have any success.

aaronmk2 Junior Poster in Training

I understand that you are allocating memory for Stack, buy do not understand after :: and I thought that you only used :: when declaring classes not in the classes.
[CODE] myTop= new Stack::Node(original.top());[/CODE]
I can post the function class of the entire program if need be.

Thanks that makes sense, i still can't figure out why I am getting a run tim error.

aaronmk2 Junior Poster in Training

The if statment I am using in my main program is not working, it should return the else value, but is returning the information in the if part of the statment and then it causes a run time error. I am not sure what is going wrong.
[CODE]
que1.add("Fish");
que1.add("Whale");
que1.add("Shark");
Que que3(que1);
que = que1;
cout<<que1.remove()<<endl;
cout<<que1.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl;

if(!que1.isEmpty())//error happens here
{  
Que que4(que1);
cout<<que4.remove()<<endl;
cout<<que4.remove()<<endl;
}
else
{
cout<<"Is empty"<<endl;
}

[/CODE]

here is the class file. I don't understand why isEmpty is not working.

[CODE]Que::~Que()
{

/*Node * temp = rear;

while (rear)
    {
      temp = rear->getLink();
      delete rear;
      rear = temp;
    }*/

}
Que::Que()
{
front=NULL;
rear = NULL;
}
Que::Que(const Que &obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker) //if node not empty
{

    copy->setLink(new Node(walker->getData(), NULL));//set values for new node
    walker=walker->getLink(); //creates link
    copy=copy->getLink();
}
front = copy; //set value to front

}

void Que::operator=(const Que & obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker)
{

    copy->setLink(new Node(walker->getData(), NULL));
    walker=walker->getLink();
    copy=copy->getLink();
}
front = copy;

}
void Que::add(string file)
{
if(front==NULL && rear==NULL) //if node
{
front = new Node(file, NULL); //creates first node
rear=front;
}
else
{
front->setLink(new Node(file, NULL)); //sets link for node ...

aaronmk2 Junior Poster in Training

The if statment I am using in my main program is not working, it should return the else value, but is returning the information in the if part of the statment and then it causes a run time error. I am not sure what is going wrong.
[CODE]
que1.add("Fish");
que1.add("Whale");
que1.add("Shark");
Que que3(que1);
que = que1;
cout<<que1.remove()<<endl;
cout<<que1.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl;

if(!que1.isEmpty())//error happens here
{  
Que que4(que1);
cout<<que4.remove()<<endl;
cout<<que4.remove()<<endl;
}
else
{
cout<<"Is empty"<<endl;
}

[/CODE]

here is the class file. I don't understand why isEmpty is not working.

[CODE]Que::~Que()
{

/*Node * temp = rear;

while (rear)
    {
      temp = rear->getLink();
      delete rear;
      rear = temp;
    }*/

}
Que::Que()
{
front=NULL;
rear = NULL;
}
Que::Que(const Que &obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker) //if node not empty
{

    copy->setLink(new Node(walker->getData(), NULL));//set values for new node
    walker=walker->getLink(); //creates link
    copy=copy->getLink();
}
front = copy; //set value to front

}

void Que::operator=(const Que & obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker)
{

    copy->setLink(new Node(walker->getData(), NULL));
    walker=walker->getLink();
    copy=copy->getLink();
}
front = copy;

}
void Que::add(string file)
{
if(front==NULL && rear==NULL) //if node
{
front = new Node(file, NULL); //creates first node
rear=front;
}
else
{
front->setLink(new Node(file, NULL)); //sets link for node ...

aaronmk2 Junior Poster in Training

I am tring to remove three string from a que using nodes. When I try to remove the third one it does so, but then I get a debugging error. I think the problem is that I am not deleting the last node but I cannot figure out what I am doing wrong.

[CODE] que1.add("Fish");
que1.add("Whale");
que1.add("Shark");
Que que3(que1);
que = que1;
cout<<que1.remove()<<endl;
cout<<que1.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl;
cout<<que3.remove()<<endl; //this causes the run time error

if(!que1.isEmpty())//this causes the run time error
{
Que que4(que1);
cout<<que4.remove()<<endl;
cout<<que4.remove()<<endl;
}
else
{
    cout<<"Is empty"<<endl;
}

return 0;

}[/CODE]

here is the que.cpp file

[CODE]Que::~Que()
{

Node * temp = front;

while (front)
    {
      temp = front->getLink();
      delete front;
      front = temp;
    }

}
Que::Que()
{
front=NULL;
rear = NULL;
}
Que::Que(const Que &obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker) //if node not empty
{

    copy->setLink(new Node(walker->getData(), NULL));//set values for new node
    walker=walker->getLink(); //creates link
    copy=copy->getLink();
}
front = copy; //set value to front

}

void Que::operator=(const Que & obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker)
{

    copy->setLink(new Node(walker->getData(), NULL));
    walker=walker->getLink();
    copy=copy->getLink();
}
front = copy;

}
void Que::add(string file)
{
if(front==NULL && rear==NULL) //if node
{
front = new Node(file, NULL); //creates first node
rear=front;
}
else ...

aaronmk2 Junior Poster in Training

que.print is not working and I cannot figure out why not
I posted a lot of code because I cannot figure out where the error is, I think it is in que.cpp, but I am nto sure what is wrong.

Here is the main

[CODE]#include "Stack.h"

include "Que.h"
include
include
include

using namespace std;
int main()

{
string file;
Stack stack;
Que que;
ifstream inputFile;
inputFile.open("text.txt");
while(inputFile.good())
{
inputFile >> file;
stack.push(file);
que.add(file);
}
stack.printStack();
que.print(); //not working

return 0;

}[/CODE]
here is the h file
[CODE] #ifndef QUEUE

define QUEUE
include "Node.h"

class Que
{
private:
Node front;
Node
rear;
void printHelper(Node *);

public:
Que();
Que(const Que &);
~Que();
void add(string);
string remove();
bool isEmpty() const;
void operator=(const Que &);
void print();

};

endif

[/CODE]
here is the cpp file for que

[CODE]#include "Que.h"

include "Stack.h"
include

using namespace std;

Que::~Que()
{

Node * temp = front;

while (front)
    {
      temp = front->getLink();
      delete front;
      front = temp;
    }

}
Que::Que()
{
front=NULL;
rear = NULL;
}
Que::Que(const Que &obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker)
{

    copy->setLink(new Node(walker->getData(), NULL));
    walker=walker->getLink();
    copy=copy->getLink();
}
front = copy;

}

void Que::operator=(const Que & obj)
{
Node walker;
Node
copy;
walker= obj.rear;
if(obj.isEmpty()){//check to see if node is null
front=NULL;
rear=NULL;
return;
}
copy=new Node(walker->getData(), NULL);//set to copy first node
rear =copy;
walker=walker->getLink();
while(walker)
{

    copy->setLink(new ...

Thank you, if are ever in Seattle and 21 or over I'll buy you a beer

aaronmk2 Junior Poster in Training

I commented by the last line. I am trying to print out the string in reverse.
[CODE]

include

using namespace std;
void add(string n);

int main()
{
string B ="ABCDEF";
add(B);

}

void add(string n)
{
if(n.length() <= 1)
{
cout<<n[0]<<endl;
return;
}
else
{
cout<<n[n.length()-1];
add(n[n.length()-1]); //this lines does not work cannot covert char to string
}

}[/CODE]