Re: obj function hello()



gert wrote:
#include <stdio.h>

obj function hello(){
struct obj = { char *data = 'hello'}
obj.add = obj_add(obj);
return obj;
}

void function obj_add(obj){
obj function add(value){
obj.data += value;
return obj;
}
}

void main(){
test = hello();
test.add('world');
printf(test.data);
}

I don't know much c and i was hoping the code above was pointing out
what i am trying to do ?

You are attempting to write something almost, but not entirely, unlike
C. It is more like JavaScript.

You can't bind functions (or anything else) to structs at runtime in C.

--
Ian Collins.
.



Relevant Pages

  • Re: obj function hello()
    ... void function obj_add{ ... obj function add{ ... better off reading a test book until you've got the general idea. ... in some alphabets" - X3.4, ...
    (comp.lang.c)
  • Re: obj function hello()
    ... void function obj_add{ ... obj function add{ ... maybe some #define and typedef. ... Why don't you use Java or C+ ...
    (comp.lang.c)