Hi Joe,

thanks a lot for your explanation of class interfaces! Though i was not the one 
who asked, your text was quite helpful.

>> Class interfaces are also one of RB's alternatives to Function Pointers.

How will this work? On Wikipedia i found this sample in C, and i wonder how you 
can get this to work in RB. (I did not figure it out). Any clues?

-----------------------------------------------------------
-----------------------------------------------------------
#include <stdio.h>

int sum = 0;             /* store sum */
int product = 1;         /* store product */

void fsum(int value)
{ sum += value; }

void fproduct(int value)
{ product *= value; }

void map_function_on_list(list *L, void (*functionptr)(int))
{
  listnode *node;
  node = L->first;
  while (node != NULL)
  {
    functionptr(node->value); /* call function pointer */
    node = node->next;
  }
}

int main()
{
  list *L; 
  ... fill list with values ...
  
  map_function_on_list(L, fsum);     /* calculate the sum */
  map_function_on_list(L, fproduct); /* calculate product */

  printf("Sum: %d\nProduct %d\n", sum, product); /* display results */
}
------------------------------------------------------------------
------------------------------------------------------------------



best regards
Thomas
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to