i am trying to use functions declared in my class file but keep getting these types of errors:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'Maze::Maze()' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
Error: Unresolved external 'Maze::assign_dimensions(int, int)' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
Error: Unresolved external 'Maze::assign_maze_data(int&, int&, char)' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
here are the files:
mazeIn.dat:
20 7
0 18
6 12
xxxxxxxxxxxxxxxxxx x
x x xxxx x
x xxxxx xxxxx xx x
x xxxxx xxxxxxx xx x
x x xx xx x
x xxxxxxxxxx xx x
xxxxxxxxxxxx xxxxxxx
//maze.h
#ifndef _MAZE_H
#define _MAZE_H
class Maze {
public:
char **maze;
int enterX;
int enterY;
int exitX;
int exitY;
Maze();
void assign_maze_data(int &i,int &j,char data);
void assign_dimensions(int choice,int data);
int getData(int choice);
};
#endif
//maze.cpp
#include <fstream.h>
#include <stdlib.h>
#include "maze.h"
ifstream infile("mazeIn.dat",ios::in);
int dimensions;
Maze::Maze() {
int x,y;
infile >> x >> y;
//create 2d array
maze=new char*[x];
for(int i=0;i<x;i++)
maze=new char[y];
}
void assign_dimensions(int choice,int data) {
if(choice==1) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
exitX=dimensions;
}
else if(choice==2) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
exitY=dimensions;
}
else if(choice==3) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
enterX=dimensions;
}
else if(choice==4) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
enterY=dimensions;
}
}
void assign_maze_data(int &i,int &j,char maze_data) {
maze[j]=maze_data;
}
int getData(int choice) {
if(choice==1) {
return exitX;
}
else if(choice==2) {
return exitY;
}
else if(choice==3) {
return enterX;
}
else if(choice==4) {
return enterY;
}
}
infile.close();
//mazemain.cpp
#include <fstream.h>
#include <stdlib.h>
#include "maze.h"
int main() {
//variable declarations
ifstream infile("mazeIn.dat",ios::in);
ofstream outfile("mazeOut.dat",ios:ut);
int width,height,dim;
char data; //wall or path
//get maze dimensions from file
infile >> width >> height;
Maze myMaze;
cout << width << " " << height;
myMaze.assign_dimensions(1,5);
//assign maze walls and paths (i.e. values) to array
for(int j=0;j<height;j++) {
for(int i=0;i<width;i++) {
while(!infile.eof()) {
infile >> noskipws >> data;
myMaze.assign_maze_data(i,j,data);
}
}
}
cout << endl;
infile.close();
outfile.close();
system("pause"
return 0;
}
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'Maze::Maze()' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
Error: Unresolved external 'Maze::assign_dimensions(int, int)' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
Error: Unresolved external 'Maze::assign_maze_data(int&, int&, char)' referenced from F:\MY DOCUMENTS\SCHOOL\CS\385\MAZE\MAZEMAIN.OBJ
here are the files:
mazeIn.dat:
20 7
0 18
6 12
xxxxxxxxxxxxxxxxxx x
x x xxxx x
x xxxxx xxxxx xx x
x xxxxx xxxxxxx xx x
x x xx xx x
x xxxxxxxxxx xx x
xxxxxxxxxxxx xxxxxxx
//maze.h
#ifndef _MAZE_H
#define _MAZE_H
class Maze {
public:
char **maze;
int enterX;
int enterY;
int exitX;
int exitY;
Maze();
void assign_maze_data(int &i,int &j,char data);
void assign_dimensions(int choice,int data);
int getData(int choice);
};
#endif
//maze.cpp
#include <fstream.h>
#include <stdlib.h>
#include "maze.h"
ifstream infile("mazeIn.dat",ios::in);
int dimensions;
Maze::Maze() {
int x,y;
infile >> x >> y;
//create 2d array
maze=new char*[x];
for(int i=0;i<x;i++)
maze=new char[y];
}
void assign_dimensions(int choice,int data) {
if(choice==1) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
exitX=dimensions;
}
else if(choice==2) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
exitY=dimensions;
}
else if(choice==3) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
enterX=dimensions;
}
else if(choice==4) {
for(int x=1;x<=choice;x++) {
infile >> dimensions;
}
enterY=dimensions;
}
}
void assign_maze_data(int &i,int &j,char maze_data) {
maze[j]=maze_data;
}
int getData(int choice) {
if(choice==1) {
return exitX;
}
else if(choice==2) {
return exitY;
}
else if(choice==3) {
return enterX;
}
else if(choice==4) {
return enterY;
}
}
infile.close();
//mazemain.cpp
#include <fstream.h>
#include <stdlib.h>
#include "maze.h"
int main() {
//variable declarations
ifstream infile("mazeIn.dat",ios::in);
ofstream outfile("mazeOut.dat",ios:ut);
int width,height,dim;
char data; //wall or path
//get maze dimensions from file
infile >> width >> height;
Maze myMaze;
cout << width << " " << height;
myMaze.assign_dimensions(1,5);
//assign maze walls and paths (i.e. values) to array
for(int j=0;j<height;j++) {
for(int i=0;i<width;i++) {
while(!infile.eof()) {
infile >> noskipws >> data;
myMaze.assign_maze_data(i,j,data);
}
}
}
cout << endl;
infile.close();
outfile.close();
system("pause"
return 0;
}