[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

array af funktioner, initialisering og kald af dem.



Hej

jeg har et lille problem med korrekte erklæringer i C++ for et array af
funktioner.

Følgende er ikke helt korrekt, men med lidt fantasi kan man forestille
sig, hvad jeg mener.

Jeg har tre funktioner som følger

  int adecode(char *p, char *t);
  int vdecode(char *p, char *t);
  int tdecode(char *p, char *t);

Dernaest har jeg funktionenerne

  void setup(int index, int (*decode)(char *p, char *t)) {
    my_array[index] = decode;
  }

  int decode_demuxer(int index, char *p, char *t) {
    return my_array[index](p, t);
  }

Saa vil jeg gerne kunne kalde setup som f.eks.

   setup(512,vdecode);
   setup(513,adecode);

og dernaest vil jeg gerne kunne kalde

  decode_demuxer(512, p, t);

Mine spørgsmål er så

a) Hvordan skal setup erklæres korrekt ?
b) hvordan skal my_array erklæres korrekt ?
c) hvordan lægges funktionerne korrekt ind i my_array ?
d) hvordan kaldes de korrekt i decode_demuxer ?

Med venlig hilsen

Peter



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-03-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *