Pointer la functie

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++
Post Reply
vili_c++
Junior
Junior
Posts: 19
Joined: 11 Feb 2014, 23:39
Judet: Dolj

Pointer la functie

Post by vili_c++ » 14 Aug 2014, 17:50

Mai jos am facut un cod simplu in care am declarat un pointer la functie.
De ce adresa functiei "number" (cel putin mie) imi este afisata ca fiind 1 ?

Code: Select all

#include <iostream>
using namespace std;
void number(int&);

int main()
{
    int x;
    void (*pF)(int&);
    pF = &number;
    (*pF)(x);
    cout << "\n Adresa functiei \"number\" este " << &number << endl;
    return 0;
}

void number(int &n)
{

}



User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3776
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

Re: Pointer la functie

Post by Ovidiu Cucu » 30 Aug 2014, 20:19

Ce compilator folosesti? Poate face cinestiece optimizari, tinand cont ca functia ta nu face nimic. Da acelasi rezultat si cand rulezi in mod DEBUG?

vili_c++
Junior
Junior
Posts: 19
Joined: 11 Feb 2014, 23:39
Judet: Dolj

Re: Pointer la functie

Post by vili_c++ » 07 Sep 2014, 16:28

Folosesc CodeBlocks.
Nu, in mod debug imi da un rezultat hexazecimal.

Scuze de intarziere, am fost in concediu.

User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3776
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

Re: Pointer la functie

Post by Ovidiu Cucu » 15 Sep 2014, 11:08

Atunci foarte probabil este asa cum am zis in postul anterior.

Post Reply