Eclipse方法无法在一个简单的程序C ++中解决 [英] Eclipse Method could not be resolved in a simple program C++
问题描述
我有一个问题,Eclipse Indigo抱怨一个类的方法无法解决,但编译反正和工作正常(AFAIK)。这是一个非常简单的程序。这里是Population.cpp:
I have an issue with Eclipse Indigo complaining that methods of a class couldn't be resolved, but compiling anyway and working correctly (AFAIK). It's a very simple program. Here is Population.cpp:
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include "Population.h"
Population::Population() {
// TODO Auto-generated constructor stub
}
Population::~Population() {
// TODO Auto-generated destructor stub
}
void Population::initializePop(int numBits, int N) {
srand((unsigned)time(0));
for(int i=0; i<N; i++) {
x[i] = (char*) calloc(numBits, sizeof(char));
for(int j=0; j<numBits; j++) {
if( rand() < 0.5 )
x[i][j] = 0;
else
x[i][j] = 1;
}
}
}
char** Population::getX() {
return x;
}
void Population::printStuff() {
std::cout << "Whatever";
}
现在,我构建该代码,一切都很好。在Eclipse中的另一个项目中,我将这样的代码调用:
Now, I build that code and everything is fine. In another project within Eclipse, I'm calling this code like this:
#include <typeinfo>
#include <string.h>
#include <iostream>
#include "cute.h"
#include "ide_listener.h"
#include "cute_runner.h"
#include "Population.cpp"
void testPopulationGeneration() {
Population* p = new Population;
int N = 10;
int bits = 4;
char** pop;
ASSERTM("Population variable improperly initialized", dynamic_cast<Population*>(p));
std::cout << p->printStuff();
std::cout << "Ok...";
p->initializePop(bits, N);
pop = p->getX();
ASSERTM("Pop not correct size.", sizeof(pop) == 10);
}
正如你所看到的,我也在C ++中运行TDD的CUTE插件。它不抱怨,当我声明p类型Population和第一个断言通过。我有点新C ++,但我确实要添加项目Population.cpp从测试项目的包含路径。
As you can see I'm also running the CUTE plugin for TDD in C++. It doesn't complain when I declare p as type Population and the first assertion passes. I'm somewhat new to C++, but I did make sure to add the project that Population.cpp is from to the include path for the test project.
这不是一个巨大的交易,因为它不影响任何明显的对我,但它仍然非常恼人。我没有看到它应该这样做的情况。
It's not a huge deal as it's not affecting anything obvious to me, but it's still very annoying. I don't see a situation where it should do this.
感谢任何帮助!
推荐答案
尝试:
在您的项目浏览器窗口中,右键单击您的项目 - >索引 - >重建
In your project explorer window, right click on your project -> Index -> Rebuild
这篇关于Eclipse方法无法在一个简单的程序C ++中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!