Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem sa statickom funkcijom

[es] :: C/C++ programiranje :: C/C++ za početnike :: Problem sa statickom funkcijom

[ Pregleda: 1784 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Rato iks de
Ratomir Vukadin
Software Engineer
Sarajevo

Član broj: 254175
Poruke: 68
89.111.226.*



+3 Profil

icon Problem sa statickom funkcijom10.03.2010. u 20:25 - pre 172 meseci
Imam problem sa sledecom kodom:

void (myClass::*PMF) ();
PMF=myClass::ShowMember;

Kasnije pravim objekte tj. obj1,obj2,obj3.

myClass obj1;
(obj1.*PMF) ();
cout<<"Static: " << myClass::GetStatic() << endl; itd.

Kompajler mi izbaci grsku da ne mogu da koristi clanove funkcije void myClass::ShowMember()
i da ne mogu da konvertujem void myClass u void myClass::*PMF
Zelim ovde da napravim pointer za pristup podatku i da upotrebim taj pointer za prikaz tog podatka.
Ako moze pomoc kako da rijesim ovaj problem.

Jos samo jedno.Kako da napravim CODE i da tu napisem kod a da nekucam ovako kodove.
Izgleda CODE: //pa ovde ide kod .Valjda sam bio jasan.
HVALA
 
Odgovor na temu

kiklop74
Darko Miletić
Buenos Aires

Član broj: 78422
Poruke: 569
200.49.157.*

Sajt: ar.linkedin.com/pub/darko..


+13 Profil

icon Re: Problem sa statickom funkcijom10.03.2010. u 21:08 - pre 172 meseci
Procitaj ovaj FAQ: http://www.parashift.com/c++-faq-lite/pointers-to-members.html

Posebno ovaj deo:

Citat:

[33.1] Is the type of "pointer-to-member-function" different from "pointer-to-function"?

Yep.

Consider the following function:

int f(char a, float b);

The type of this function is different depending on whether it is an ordinary function or a non-static member function of some class:

* Its type is "int (*)(char,float)" if an ordinary function
* Its type is "int (Fred::*)(char,float)" if a non-static member function of class Fred

Note: if it's a static member function of class Fred, its type is the same as if it were an ordinary function: "int (*)(char,float)".

Tko leti vrijedi
 
Odgovor na temu

[es] :: C/C++ programiranje :: C/C++ za početnike :: Problem sa statickom funkcijom

[ Pregleda: 1784 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.