Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 1 odgovor
  • 2.384 pregleda

Najnovija ↓

Problem sa statickom funkcijom 10.03.2010. u 21:25 · pre 202 meseca #1
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
Re: Problem sa statickom funkcijom 10.03.2010. u 22:08 · pre 202 meseca #2
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)".
Potpis
Tko leti vrijedi
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme