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

Aug 19, 2014 at 2:39pm
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?
Aug 19, 2014 at 3:46pm
Is this a compiler error or a runtime error?
Aug 19, 2014 at 4:51pm
compiler error
Aug 19, 2014 at 4:57pm
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 Aug 19, 2014 at 5:04pm
Aug 19, 2014 at 6:04pm
Disch wrote:
but when I submit to IDEone it fails.
Compiles for me on ideone with some minor changes http://ideone.com/NO99PS
Aug 19, 2014 at 6:18pm
Ah... it was the pure virtual thing.
Topic archived. No new replies allowed.