Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?
I know this problem gets answered all the time, but I haven't been able to find a solution for my specific example. Here's the full error:
g++ main.cpp
Undefined symbols for architecture x86_64:
"Board::display()", referenced from:
_main in cc7hPZpy.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I'm just trying to pull this display function from my Board class. Here's main:
#include "Board.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Some Asian Game" << endl;
Board base;
base.display();
//this is creating the error
//commenting it out compiles, but obviously does not do what i want.
return 0;
}
and Board.h:
#ifndef Board_H
#define Board_H
#include "Row.h"
#include <vector>
using namespace std;
class Board
{
public:
vector<Row> rows;
Board()
{
vector<Row> (15);
}
void play(int row, int col, char clr);
bool checkWin(int row, int col, char clr);
char getCellColor(int row, int col);
void display();
void empty();
};
#endif
and the particular function in question from board.cpp
void Board::display()
{
for(int i=0;i<16;i++)
{
for(int i2=0;i2<16;i2++)
{
cout << rows[i].cells[i2].getState();
}
}
}
I've referred to this site often for answers, but have never used it personally, so bear with me on responding. I'm pretty positive this is something simple that I'm just overlooking though.