1 / 7

Ponteiros para Funções

Ponteiros para Funções. Lauro Moura lauromoura@gmail.com. Roteiro. Introdução Sintaxe Exemplos Exercícios Rerefências. Introdução. Como qualquer variável, uma função possui um endereço na memória e pode ser referenciada por um ponteiro Labels em assembly

nixie
Télécharger la présentation

Ponteiros para Funções

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ponteiros para Funções Lauro Moura lauromoura@gmail.com

  2. Roteiro • Introdução • Sintaxe • Exemplos • Exercícios • Rerefências

  3. Introdução • Como qualquer variável, uma função possui um endereço na memória e pode ser referenciada por um ponteiro • Labels em assembly • Útil para substituir switch/if e para funções callback • Listeners de java

  4. Sintaxe em C • Declaração: • <retorno> (*<nome>)(<lista de parâmetros>); • Ponteiro para função que recebe dois int’s e retorna um float • float (*my_func)(int, int); • Chamada: • (*<nome>)(<lista de parâmetros>);

  5. Exemplo: • Uso simples de pointeiro para função: • check.c • Substituindo um if/else: • check_num.c

  6. Exercícios - 1 • Faça uma função que

  7. Referências • C Completo e Total – Schildt Herbert – Markron Books • The Function Pointer Tutorial • http://www.newty.de/fpt/index.html

More Related