Strange error on lines .text+0x220

I'm going to appologise in advance for posting so much. But, I have no idea where the error actually is so, sorry...

When I attempt to compile, I get these error messages from g++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/tmp/ccPHFQII.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x71): undefined reference to `organism_cell::organism_cell(char)'
main.cpp:(.text+0x86): undefined reference to `organism_cell::organism_cell(char)'
main.cpp:(.text+0xa2): undefined reference to `organisms::organisms()'
/tmp/ccPHFQII.o: In function `aliveOrDead(organism_cell, organism_cell, organism_cell, organism_cell, organism_cell)':
main.cpp:(.text+0xee): undefined reference to `organism_cell::operator==(organism_cell const&)'
main.cpp:(.text+0x109): undefined reference to `organism_cell::operator==(organism_cell const&)'
main.cpp:(.text+0x124): undefined reference to `organism_cell::operator==(organism_cell const&)'
main.cpp:(.text+0x13f): undefined reference to `organism_cell::operator==(organism_cell const&)'
main.cpp:(.text+0x184): undefined reference to `organism_cell::operator==(organism_cell const&)'
/tmp/ccPHFQII.o:main.cpp:(.text+0x1b9): more undefined references to `organism_cell::operator==(organism_cell const&)' follow
/tmp/ccPHFQII.o: In function `calcNextGen(organisms, int)':
main.cpp:(.text+0x220): undefined reference to `organisms::operator[](int)'
main.cpp:(.text+0x23b): undefined reference to `organisms::operator[](int)'
main.cpp:(.text+0x253): undefined reference to `organisms::operator[](int)'
main.cpp:(.text+0x26e): undefined reference to `organisms::operator[](int)'
main.cpp:(.text+0x289): undefined reference to `organisms::operator[](int)'
/tmp/ccPHFQII.o:main.cpp:(.text+0x364): more undefined references to `organisms::operator[](int)' follow
/tmp/ccPHFQII.o: In function `calcNextGen(organisms, int)':
main.cpp:(.text+0x37d): undefined reference to `organism_cell::operator=(char)'
/tmp/ccPHFQII.o: In function `begin(char*, int, int)':
main.cpp:(.text+0x3b3): undefined reference to `organisms::organisms(int)'
main.cpp:(.text+0x3db): undefined reference to `organisms::operator=(organisms const&)'
main.cpp:(.text+0x46e): undefined reference to `organisms::operator[](int)'
main.cpp:(.text+0x49b): undefined reference to `organism_cell::operator=(organism_cell const&)'
main.cpp:(.text+0x4b0): undefined reference to `organism_cell::operator=(organism_cell const&)'
main.cpp:(.text+0x4ed): undefined reference to `calcNextGen(organisms*, int)'
collect2: ld returned 1 exit status 


My code main is as follows,,,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "organisms.h"
#include <string>
#include <fstream>
#include <iostream>

using namespace std;


void begin(char temp[], int num, int i);
void calcNextGen(organisms next[], int num);
char aliveOrDead(organism_cell m2, organism_cell m1, organism_cell oc, organism_cell p1, organism_cell p2);
void read();
void print();


const organism_cell alive('*');

const organism_cell dead(' ');



organisms history[10000];


int main( ) 
{
	

}

void read()
{
	string in;
	int num = 0;
	cout << "Please enter the path to the file you wish to read:" << endl;
	cin >> in;
	
	char temp[50];
	char cont;
	int i = 0;

	ifstream fin(in.c_str());

	while(fin >> cont) 
	{
		temp[i] = cont;
	
		if(i == 50) //Just in case the input file is giving mroe then it should.
			break;

		i++;
	}

	cout << "How many generations do you want to run? \n\t(No more then 10000)" << endl;
	cin >> num;

	begin(temp, num, i);
}

void begin(char seed[], int num, int i)
{
	for(int j = 0; j < num; num)  //Set all the organisms (that are needed to be set)
		history[i] = organisms(i);

	organisms h = history[0];

	for(int j = 0; j < i; j++)
	{
		organism_cell he = h[j];

		if(alive.o_alive == seed[j])
			he = alive;
		else
			he = dead;
	}

	for(int j = 0; j < num-1; j++)
		calcNextGen(history + j, j);
}

void calcNextGen(organisms next, int num)
{
	
	for(int i = 0; i < num; i++)
	{
		if(i > 1 || i < num-3)  //The easy cases
		{
			organism_cell ocm2 = next[i-2];  
			organism_cell ocm1 = next[i-1];
			organism_cell oc = next[i];
			organism_cell ocp1 = next[i+1];
			organism_cell ocp2 = next[i+2];

			char c = aliveOrDead(ocm2, ocm1, oc, ocp1, ocp2);

			organisms work = history[num+1];
			organism_cell wo = work[i];
			wo = c;

		}
	}
}

char aliveOrDead(organism_cell ocm2, organism_cell ocm1, organism_cell oc, organism_cell ocp1, organism_cell ocp2)
{
	int life = 0;

	if(ocm2 == alive)
		life++;
	if(ocm1 == alive)
		life++;
	if(ocp1 == alive)
		life++;
	if(ocp2 == alive)
		life++;

	if(life < 2)
		return dead.o_alive;
	if(life == 2)
		return alive.o_alive;
	if(life == 3)
		if(oc == alive)
			return dead.o_alive;
		else
			return alive.o_alive;
	if(life == 4)
		if(oc == dead)
			return dead.o_alive;
		else
			return alive.o_alive;		
}

void print()
{
	
}






Again...I'm sorry about posting all of that. Also, if you need either organism_cell or organisms posted I'll be happy to do so.

Thanks a lot for the help.
Also, if you need either organism_cell or organisms posted I'll be happy to do so.
Yes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//------------------------------------------------------------------------------

// Filename:    organisms.h



#ifndef ORGANISMS_H

#define ORGANISMS_H



using namespace std;



extern int num_cells;  // define this in the source.cpp file

extern int num_gens;   // define this in the source.cpp file



const int MAX_CELLS = 50;



//------------------------------------------------------------------------------

class organism_cell 
{

	

public:
	char o_alive;           // ‘*’ for alive, ‘ ’ for dead

	organism_cell( );       // constructor makes organism dead

	organism_cell(char c);  // if c is valid, sets organism to state specified

	char status( );         // returns the value of alive



	organism_cell &operator=(char c);        // sets alive to c, if allowed

	organism_cell &operator=(const organism_cell &O); // makes a copy

	bool operator==(const char c);                 // checks status of organism

	bool operator==(const organism_cell &O);       // checks for equality

};





//------------------------------------------------------------------------------

class organisms 
{

	organism_cell orgs[MAX_CELLS]; // at most MAX_CELLS organisms will be present 

	int num_cells;		       // number of organism cells in use (determined

				       //           while reading input file)

public:

	organisms( );		   // sets all organism cells to be dead

	organisms(int size);       // sets num_cells and makes all organisms dead



	void set_size(int size);   // change the size of the row



	const organism_cell &operator[](int i);  // access organism_cell at postion i

	organisms &operator=(const organisms &O); // make row equal to that of O

	bool operator==(const organisms &O);  // check if rows are equal

};

#endif


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//------------------------------------------------------------------------------

// Filename:    organisms.cpp


#include <stdlib>

#include <cstdlib>        // we need the exit() function from here, maybe others too

#include "organisms.h"
using namespace std




//------------------------------------------------------------------------------

organism_cell::organism_cell( )        // constructor makes organism dead
{

	organism_cell::o_alive = dead.status();

}



//------------------------------------------------------------------------------

organism_cell::organism_cell(char c)  // if c is valid, sets organism to state specified

{

  if('*' == c || ' ' == c)
	organism_cell::o_alive = c;



}



//------------------------------------------------------------------------------

char organism_cell::status( )       // returns the value of alive

{

 	return o_alive;

}



//------------------------------------------------------------------------------

organism_cell &organism_cell::operator=(char c)  // sets alive to c, if allowed

{

	if(alive == c || dead == c)
		organism_cell::o_alive = c;

}



//------------------------------------------------------------------------------

organism_cell &organism_cell::operator=(const organism_cell &O)  // makes a copy

{

	o_alive = O.o_alive;

	return *this;

}



//------------------------------------------------------------------------------

bool organism_cell::operator==(const char c)              // checks status of organism

{

	if(organism_cell::o_alive == c)
		return true;
	else
		return false;

}



//------------------------------------------------------------------------------

bool organism_cell::operator==(const organism_cell &O)       // checks for equality

{

	if(o_alive == O.o_alive)
		return true;
	else
		return false;

}





//------------------------------------------------------------------------------

organisms::organisms( )		   // sets all organism cells to be dead

{

	for(int i = 0; i < MAX_CELLS; i++)
	{
		orgs[i] = organism_cell();
	}

}



//------------------------------------------------------------------------------

organisms::organisms(int size)       // sets num_cells and makes all organisms dead

{

	num_cells = size;
	organisms();

}



//------------------------------------------------------------------------------

void organisms::set_size(int size)   // change the size of the row

{

	num_cells = size;

}



//------------------------------------------------------------------------------

const organism_cell &organisms::operator[] (int i)    // access organism_cell at postion i
{



	if ((i>=0) && (i<num_cells)) 
	{

		return orgs[i];

	}

	else    // this is an error
	{

		cout << "Index out of range in organisms::operator[]()" << endl;

		cout << "Exiting" << endl;

		exit(1);

	}

	return NULL;

}



//------------------------------------------------------------------------------

organisms &organisms::operator=(const organisms &O) 
{

	for(int i = 0; i < num_cells; i++)
	{
		this[i] = [i];
	}

	return *this;

}



//------------------------------------------------------------------------------

bool organisms::operator==(const organisms &O)

{

	for(int i = 0; i < num_cells; i++)
	{
		if(this[i] != O[i])
		return false;
	}

	return true;

}
Are you linking ccPHFQII.cpp and organisms.cpp together? If you're using an IDE, this is done by adding the file to the project.
That's my problem, in my folder (/home/user/workspace/Test) there are only these three files. Using the terminal and g++ (dir to the directory and then issue "g++ main.cpp") I get this error.
To compile several files as one executable:
g++ a.cpp b.cpp c.cpp -o program
Topic archived. No new replies allowed.