What's worng with this class with a pointer member?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class cell_c:public point_c {
public:
        double p;
	std::vector<const cell_c *> NP;// 8 Neighbors Pointer
        virtual bool calculateFD(numeric_t & FAe, numeric_t & FAw, numeric_t & FAn, numeric_t & FAs,
			                 numeric_t & DAe, numeric_t & DAw, numeric_t & DAn, numeric_t & DAs);
	cell_c() {
             p=0;

		for(size_t i=0; i!=8; ++i) {

			NP.push_back(nullptr);
		}
	}
};



1
2
3
4
5
6
class uCell_c:public cell_c {

public:
bool calculateFD(numeric_t & FAe, numeric_t & FAw, numeric_t & FAn, numeric_t & FAs,
			                 numeric_t & DAe, numeric_t & DAw, numeric_t & DAn, numeric_t & DAs);
};


1
2
3
4
bool uCell_c::calculateFD(numeric_t & FAe, numeric_t & FAw, numeric_t & FAn, numeric_t & FAs,
			                 numeric_t & DAe, numeric_t & DAw, numeric_t & DAn, numeric_t & DAs) {
    FAe=p+NP[0]->p;//p cannot be resolved, why?
}


cannot I use NP like that?
Is this a compiler error or a runtime error?
compiler error
EDIT: Hmm.. actually it only works in VS -- gcc seems to give the linker error. Nevermind!

After filling in some unknown types... the code compiles just fine for me. Your problem must be in code you are not showing us.

EDIT2: Okay so my local version of GCC and VS it works... but when I submit to IDEone it fails. What compiler are you using?
Last edited on
Disch wrote:
but when I submit to IDEone it fails.
Compiles for me on ideone with some minor changes http://ideone.com/NO99PS
Ah... it was the pure virtual thing.
Topic archived. No new replies allowed.