I spent the last 3 hours trying to figure out what I'm doing wrong. I just need other views on this, I tried everything I can think of, even various random permutations in an attempt to get the compiler to tell me something useful.
This is where I am now:
the code:
class villain { public: villain(); //lots of other stuff bool Type1EnemyBlasts(); bool Type2EnemyBlasts(); bool (villain::*OnFire)(); }; villain::villain() { //lots of other stuff OnFire = &villain::Type1EnemyBlasts; } main { //lots and lots of other stuff villain *targets[100]; targets[0] = new villain(); if(targets[0]->*OnFire() == true) { //do stuff } }
The error occurs when I call "target [0] → * OnFire ()", where it states that it is not declared in this area. It seems strange to me that I have to define "OnFire" with "& villain ::" when it is defined inside an attacker, but all the information I found suggests that it should be done this way, and really if I try differently, deflates a number of errors.
What is the correct syntax for calling the * OnFire () pointer, which belongs to target [0]?
c ++ scope pointers reference function-pointers
user3542913
source share