Here is my members file:
///////////////////////////////////////////////////////////////////////////////
#include<iostream>
#include<fstream>
#include "linkedlist.h"
using namespace std;
linkedList::linkedList()
{
start_ptr=NULL;
}
linkedList::linkedList(linkedList const &otherlist)
{
int i=0;
node *temp=start_ptr;
while (i<length())
{
for(int i=0;i <length();i++)
{
thirdList.AddNode(valueAtIndex(i)+secondList.valueAtIndex(i));
}
system("PAUSE");
}
///////////////////////////////////////////////////////////////////////////////
Here is my class file:
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
class linkedList{
struct node
{
int data;
node* next;
}*tail,*start_ptr;
public:
linkedList(linkedList const &otherlist);
linkedList();
void AddNode(int num);
void DeleteNode(int item1);
int length()const;
void PrintNodes();
void divideAt(linkedList &secondlist,const int &item);
void addTo( const linkedList &secondList, linkedList &thirdList);
int valueAtIndex(int indx)const;
};
#endif
Here is the file where I try to invoke the copy constructor for a test
////////////////////////////////////////////////////////////////////////////
#include<iostream>
#include<fstream>
#include "linkedlist.h"
using namespace std;
ofstream myofstream("ListOut.txt");
void main()
{
}
int num2=0;
myifstream2>> num2;
while(myifstream2)
{
list2.AddNode(num2);
myifstream2>> num2;
}
int num3=0;
myifstream3>> num3;
while(myifstream3)
{
list3.AddNode(num3);
myifstream3>> num3;
}
linkedList list4(list1);
}
I am trying to test the copy constructor by this call:
linkedList list4(list1);
I'm not even sure if this is right....but that's why I'm asking here.
When it breaks during debugging, execution is stopped a loop in my length function. I'm confused....Any help would be much appreciated