r1 - 24 Sep 2006 - 21:15:13 - PatrickSmythYou are here: TWiki >  IBG Web  >  IBGSoft > CPseudoOOPCodingMethods

-- PatrickSmyth - 24 Sep 2006

The following code example was presented at the BioInformatics? weekly research meeting held on September 18, 2006 as an example of a coding technique to introduce Object Oriented like concepts into C.

a.h

typedef a_str = void *;

#ifndef EXTERN external #define EXTERN external #endif

EXTERN int new_a(....); EXTERN int increment_a(a-str, err_code*);

a.c

#define EXTERN #include a.h;

struct a { /* Create a flag to see if the program is using our pseudo-class */ int magic = 0x1A1C; // other attributes }

EXTERN int new_a(a_str * ret_a, err_code *) {

a* ret = malloc(size_of(a)); ret_a = (void *) ret; }

EXTERN int increment_a (a_str* ret_a, err_code *) {

if (ret_a == null) // error a* internal_a = (a*) ret_a;

if (a->magic <> 0x1A1C) // error

}

EXTERN int delete_a ( a_str*) { a->magic = 0x0; }

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Illinois Bio-Grid
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback