pointer to function c++

Started by
9 comments, last by zlatko_bre_1985 18 years, 9 months ago
I am realy sorry but i still cant make it work. :<
Here is what i tried
// test2.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <vector>#include <iostream>class image{public:	image(){};void Render();};void image::Render(){std::cout << "ASdfasdf\n";};class anim{public:	anim();	std::vector <image *> aImages;	void (image::*pFunc)(void); 	//void (std::vector<image *>::*pFunc)(); i tried with this decaration	//compiler accepts it but i still cannot set pFunc;};anim::anim(){	aImages.push_back(new image());	//pFunc = aImages.at(0)->Render;		//error C2475: 'image::Render' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name		//pFunc = anim::aImages.at(0)->Render;	//error C2475:		//pFunc = anim::aImages::at(0)::Render; //'aImages' : is not a member of 'anim'											//'Render' : is not a member of 'operator``global namespace'''											//'Render' : undeclared identifier											//mising ; before render											//'at': identifier not found, even with argument-dependent lookup	//pFunc = anim::aImages[0]->Render;		//error C2375	//pFunc = &anim::aImages[0]->Render;	//error C2276: '&' : illegal operation on bound member function expression	//pFunc = &(anim::aImages[0]->Render);	//error C2276	//pFunc = &(anim::aImages[0])->Render;	//error C2276			//and here i lost all hope i think it needs something like (pointer to image)::*pFunc };anim::~anim(){delete aImages.at(0);};int _tmain(int argc, _TCHAR* argv[]){	anim * animation;	animation = new anim();//	(animation->pFunc)();	delete animation;	return 0;}[\source]
Serbia,Zrenjanin

This topic is closed to new replies.

Advertisement