Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

function calling in c++

Name: Anonymous 2007-01-10 20:23

I'm kinda new to c++, and I have a question that I can't really define well enough for google to give me answers.

basically, what i want to do is loop through a list of classes that i know have a specific function and call it. I've tried something like
   *(ObjectArray[0] + loop).function();
where ObjectArray would be an string array that holds all of the function names. This fails, because function() is not defined, even though I've declared it in the class.

Any ideas?

Name: Anonymous 2011-04-14 12:41

>>5
C++ is a statically typed language, it doesn't have first-class member function reflection or dynamic binding. Instead, you want to use member function polymorphism (virtual functions) and a class hierarchy as >>3 pointed out.

Secondly, don't use dev-cpp. Perhaps the book you started reading uses it, but dev-cpp hasn't been updated in years, its version of GCC it uses is ancient. It has known security problems. It generates slow code. No one in the software development industry uses it.

If you're on Windows, you should be using the free and excellent Microsoft Visual C++ 2010 Express Edition. I recommend staying away from MinGW and Cygwin, they kind of blow chunks on Windows.

If you're on Linux, you should be using a recent version GCC.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List