对cell :: cell(float)的未定义引用

时间:2014-01-17 12:22:30

标签: c++ codeblocks undefined-reference

我无法理解为什么会出现以下错误,因为我已经包含了所有的库,而且一切都比它应该更公开!可能是我没有掌握的东西或者是一个愚蠢的错误..你能帮忙!!

错误: “对cell :: cell(float)的未定义引用” “undefined reference to exploration :: exploration(bool,float,int)”

忽略不存在的封装。

#include <iostream>
#include "vehicle.h"
#include "tool.h"
#include <vector>
#include <stdlib.h>
#include <time.h>
#include "exploration.h"
#include "analyze.h"
#include "repair.h"
#include "cell.h"

int main()
{
int k=0;
std::vector <cell> cells;
std::vector <Exploration> vexp;
std::vector <analyze> anal;
std::vector <Repair> reps;
srand (time(NULL));

std::cout << "Enter number of cells\n";
std::cin.clear();
std::cin >> k;
r = rand() % 100+1;
for(int i=0; i<k; i++)
{
    cell tempcell (0.1);
    cells.push_back(tempcell);
}
for(int i=1; i<9; i++)
{
    Exploration temp (0,3,3);
    vexp.push_back(temp);
}
}

cell.h:

#ifndef CELL_H
#define CELL_H
#include<vector>

class cell
{
public:
cell (float);
int Pd;
int Ir;
int Pt;
float Danger;
bool Flag;
bool Occupied;

int RandGround();
void ChangeFlag();
void ChangeGround();
};

#endif // CELL_H

cell.cpp:

#include "cell.h"
#include <time.h>
#include <stdlib.h>

cell :: cell (float Dang)
{
Pd = RandGround();
Ir = RandGround();
Pt = RandGround();
Danger = Dang;
Flag = 0;
Occupied = 0;
}


int cell::RandGround()
{
int r;
srand(time(NULL));
return r;
}

0 个答案:

没有答案