Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bolrand 5.0 unresolved external

Status
Not open for further replies.

ahaller

Programmer
Oct 16, 2002
1
US
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 &quot;maze.h&quot;

ifstream infile(&quot;mazeIn.dat&quot;,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 &quot;maze.h&quot;

int main() {
//variable declarations
ifstream infile(&quot;mazeIn.dat&quot;,ios::in);
ofstream outfile(&quot;mazeOut.dat&quot;,ios::eek:ut);
int width,height,dim;
char data; //wall or path

//get maze dimensions from file
infile >> width >> height;
Maze myMaze;
cout << width << &quot; &quot; << 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(&quot;pause&quot;);
return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top