main cpp file:
#include <iostream>
#include <cstdio>
#include "table.h"
using namespace std;
int main() {
Table test;
int i;
for(i = 0; i < 26; i++) {
cout << test.start[2] << endl;
}
system("PAUSE");
return 0;
}
header file:
#pragma once
class Table {
public:
char start[26];
Table();
Table(char key[26]);
~Table();
};
cpp file:
#include "table.h"
Table::Table() {
char start[26] = "ABCDEFGHIJKLMNOPRSTUVWXYZ";
}
Table::Table(char key[26]) {
}
errors im getting :
1>playfair.obj : error LNK2019: unresolved external symbol "public: __thiscall Table::~Table(void)" (??1Table@@QAE@XZ) referenced in function _main
1>c:\Users\Jansu\Documents\Visual Studio 2010\Projects\playfair\Debug\playfair.exe : fatal error LNK1120: 1 unresolved externals
so basically i googled a lot and do not know what to do. i found some answers but i tried them and did not help
for example i tried to add additional dependencies, but i had all of them already added.
help me please, why does the error come?
Although the header defines
Tableas having a dtor, the cpp file only contains a couple of constructors — not a destructor. Given that there seems to be nothing for your destructor to do (you haven’t allocated any dynamic memory or anything like that) you probably just want to remove the declaration ofTable::~Table();and be done with it. While you’re at it, you probably want to makeTable::startprivate. I’d also change the parameter to achar const *instead of using array notation:Once you’re done dealing with that, you’ll need to deal with the fact that
Table::Table()defines a local variable namedstart, and initializes it, but leavesTable::startuninitialized, which I doubt is what you wanted/intended.