Path: news.cs.au.dk!news.net.uni-c.dk!newspeer.ebone.net!newsfeed2.news.nl.uu.net!sun4nl!skynet.be!analog.skynet.be!poster!not-for-mail From: Atle Newsgroups: comp.lang.beta Subject: Function call? Date: Wed, 31 May 2000 11:58:21 -0100 Organization: Belgacom Skynet SA/NV Lines: 72 Message-ID: <39350C6D.3AF68913@skynet.be> NNTP-Posting-Host: dialup142.charleroi.skynet.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news0.skynet.be 959766990 20404 195.238.7.142 (31 May 2000 09:56:30 GMT) X-Complaints-To: abuse@skynet.be NNTP-Posting-Date: 31 May 2000 09:56:30 GMT X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i686) X-Accept-Language: en Xref: news.cs.au.dk comp.lang.beta:12369 Hello, good helpers! I got everything so far to go OK, but I am having trouble figuring out the 'function call' syntax. I am sure it is simpler than what I'm used to, and that is why I can't figure it out ... Let struct person be the way it was, name, addr, tlf. >From C /* * Instantiate an object of type person. * The name will be filled in, the rest will be default * values (inherited?) * The C way is to either build up structs or * pass in a subclass pointer */ struct person *new_person(char* name) { struct person *prv; /* A dynamic reference? */ prv = malloc(sizeof(struct person)); /* Create a dynamic instance? */ if ( ! prv) { perror("malloc"); return(0); /* Spoiled with automatic casting, should be (struct person*) 0 */ } strcpy(prv->name, name); /* Person has this name from input parm */ strcpy(prv->addr, sc->addr); /* Don't bother with this now */ strcpy(prv->tlf, "000"); /* Call the police */ return(prv); /* Imperative :-) that I understand enter and exit */ } void person_set(struct person *p, char *name, char *addr, char* tlf) { if (name) strcpy(p->name, name); if (addr) strcpy(p->addr, addr); if (tlf) strcpy(p->tlf, tlf); } int not_person_related(char *s) { s[0] = 'X'; return(12); } void main(int ac, char *av[]) { struct person *p; int x, y; char s[25]; p = person_new("Newman"); if ( ! p) exit(0); person_set(p, 0, "Hovden", "3716 8532"); /*-------- So far, so good. These are typically 'object' functions ---*/ /* But what with this? */ x = not_person_related(s); x = not_person_related(p->tlf); }