I am working on a project and am trying to compile as I go and I'm getting a linking problem. The main most of header file functions were given to us.
Header
Code:
#ifndef INTEGERSET_H
#define INTEGERSET_H
const int arraySize = 100;
class IntegerSet
{
public:
IntegerSet(); //Default constructor empty set
//IntegerSet( int values[], int size ); //Constructor with values
~IntegerSet();
//IntegerSet& unionSet( IntegerSet& otherSet );
//IntegerSet& intersectSet( IntegerSet& otherSet );
//void clear();
//bool isEmptySet();
bool insertElement( int elem, int count = 1 );
//bool removeElement( int elem, int count = 1 );
//bool setElementCount( int elem, int count );
//int getNumElements( int elem );
//bool isEqualTo( IntegerSet& otherSet );
void printSet();
private:
int array;
};
#endif
IntegerSet.cpp
Code:
#include "IntegerSet.h"
#include <iostream>
#include <conio.h>
#include <iomanip>
using std::cout;
using std::endl;
using std::setw;
static int array[ arraySize ];
bool IntegerSet::insertElement( int elem, int counter )
{
if( elem > 0 && elem <= arraySize )
{
return true;
}
else
return false;
}
void IntegerSet::printSet()
{
for( int idx = 0; idx < arraySize; ++idx )
cout << idx << ")" << setw( 3 ) << idx << endl;
}
main.cpp
Code:
#include "IntegerSet.h"
#include <iostream>
#include <conio.h>
using std::cout;
using std::endl;
int main()
{
int i;
IntegerSet a;
cout << "Empty Set" << endl;
a.printSet();
getch();
srand( 1234 );
for( i = 0; i < 50000; ++i )
a.insertElement( rand() % 101 );
a.printSet();
getch();
/* cout << "Random insert" << endl;
a.printSet();
getch();
int testArray[300];
for( i = 0; i < 300; ++i )
testArray[i] = rand() % 101;
IntegerSet b( testArray, 300 );
cout << "Fill from array" << endl;
b.printSet();
getch();
IntegerSet c = a;
cout << "Operator =" << endl;
c.printSet();
getch();
c.unionSet( b ).intersectSet( a );
cout << "Union b, intersect a" << endl;
c.printSet();
getch();
if( a.isEqualTo( c ) )
cout << "A and C are equivalent" << endl;
else
cout << "A and C are not equivalent" << endl;
if( b.isEmptySet() )
cout << "B is empty" << endl;
else
cout << "B is not empty" << endl;
*/
getch();
return 0;
}
Errors
Code:
MT fatal error LNK1120: 2 unresolved externals
MT error LNK2019: unresolved external symbol "public: __thiscall IntegerSet::~IntegerSet(void)" (??1IntegerSet@@QAE@XZ) referenced in function _main
MT error LNK2019: unresolved external symbol "public: __thiscall IntegerSet::IntegerSet(void)" (??0IntegerSet@@QAE@XZ) referenced in function _main
I commented out most things b/c I'm trying to go one step at a time. I would appreciate any help.