Okay, this is part of my final for my OOP c++ class, and for the life of me i can't figure out why i'm getting this linker error.
Main.obj : error LNK2001: unresolved external symbol "public: __thiscall Prob3TableInherited<int>::Prob3TableInherited<int>(char *,int,int)" (??0?$Prob3TableInherited@H@@QAE@PADHH@Z)
Debug/Final.exe : fatal error LNK1120: 1 unresolved externals
Prob3Table = base class
Prob3TableInheritance = derived class
My very newbie hunch is that it has something to do with my derived class' constructor.
Sorry for posting so much code and being such a newb.
This is the professor-written driver, it shouldnt need changes:
This is the base class Prog3Table:Code:void problem3() { cout<<"Entering problem number 3"<<endl; int rows=5; int cols=6; Prob3TableInherited<int> tab("Problem3.txt",rows,cols); //Initializes naugT to tab.table const int *naugT=tab.getTable(); //Outputs Table for(int i=0;i<rows;i++) { for(int j=0;j<cols;j++) { cout<<naugT[i*cols+j]<<" "; } cout<<endl; } cout<<endl; //Initializes augT to tab.augTable (table with summed columns/rows) const int *augT=tab.getAugTable(); for(i=0;i<=rows;i++) { for(int j=0;j<=cols;j++) { cout<<augT[i*(cols+1)+j]<<" "; } cout<<endl; } }
And this is the inherited class, Prog3TableInheritedCode:template <class T> Prob3Table<T>::Prob3Table(char *in, int row, int col) :rows(row), cols(col), grandTotal(0) { ifstream inStream; inStream.open(in); //Creates 2-dimensional array table = new T[rows*cols]; //File input to array for(unsigned int i = 0; i < rows; i++) { for(unsigned int j = 0; j < cols; j++) { inStream << augTable[i][j]; } } //Row/Col sum arrays rowSum = new T[rows] = 0; colSum = new T[cols] = 0; } template <class T> void Prob3Table<T>::calcTable() { //row sum for(unsigned int i = 0; i < rows; i++) { for(unsigned int j = 0; j < cols; j++) { rowSum[i] += table[i][j]; grandTotal += table[i][j]; } } //col sum for(i = 0; i < cols; i++) { for(j = 0; j < rows; j++) { colSum[i] += table[i][j]; grandTotal += table[i][j]; } } }
Code:#include "Prob3TableInherited.h" template <class T> Prob3TableInherited<T>::Prob3TableInherited(char *in, int row, int col) { //Aug array declared with rows+1/cols+1 to make room for totals augTable = new T[(rows+1)*(cols+1)]; //CalcTable is called from base class to calculate sums/total calcTable(); //Column sum is added to augTable columns for(i = 0; i < rows; i++) { for( j = 0; j < cols; j++) { augTable[rows+1][j] = colSum[j]; } } //Row sum is added to augTable rows for(j = 0; j < cols; j++) { for(i = 0; i < rows; i++) { augTable[i][cols+1] = rowSum[i]; } } }




Reply With Quote