Witam,
uprzejmie proszę o informację, dlaczego kompilator wywala błąd we wskazanym w komentarzu miejscu w poniższym kodzie:
#include "stdafx.h"
using namespace std;
#include <iostream>
class klasa
{
public:
void (klasa::*wsk)();
void metoda1()
{
cout << "funkcja 1" << endl;
}
void metoda2()
{
cout << "funkcja 2" << endl;
}
void set_method(int i)
{
if(i == 1)
wsk = &klasa::metoda1;
if(i == 2)
wsk = &klasa::metoda2;
}
void fun2()
{
(this->*wsk)();
}
};
int _tmain(int argc, _TCHAR* argv[])
{
klasa B;
B.set_method(2);
(B.*wsk)(); //czemu tu jest błąd?!?
B.fun2();
getchar();
return 0;
}
Chodzi oczywiście o ten fragment:
(B.*wsk)();