From: Martin Ambuhl Newsgroups: comp.os.msdos.djgpp Subject: Re: program wont compile.. Date: Mon, 30 Nov 1998 00:22:30 -0500 Content-Transfer-Encoding: 7bit References: <36617669 DOT 21761297 AT news DOT inet DOT tele DOT dk> X-Posted-Path-Was: not-for-mail X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-ELN-Date: 30 Nov 1998 05:25:01 GMT X-ELN-Insert-Date: Sun Nov 29 21:25:08 1998 Organization: Nocturnal Aviation Lines: 99 Mime-Version: 1.0 NNTP-Posting-Host: 1cust164.tnt11.nyc3.da.uu.net Message-ID: <36622B96.2267BCF6@earthlink.net> X-Mailer: Mozilla 4.5 [en] (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com langkjer wrote: > > I can't get the following prog to compile: [...] > It says: > In method 'bog::bog(char *, char *, char *)': > warning: implicit declaration of function 'int strcopy(...)' > undefinied reference to 'strcopy' (5 times) The function is called strcpy(). The following changes 66,67d 61d 59d 57d 53c int main(void) . 48,49c strcpy(fagnr, denne_bog.fagnr); . 42c strcpy(denne_bog->fagnr, andet_fagnr); . 28,30c strcpy(bog::titel, titel); strcpy(bog::forfatter, forfatter); strcpy(bog::fagnr, fagnr); . 5d 3d produce the following: #include #include class bog; class bibliotekar { public: void nyt_fagnr(bog *, char *); char *skaf_fagnr(bog); }; class bog { public: bog(char *, char *, char *); void vis_bog(void); friend char *bibliotekar::skaf_fagnr(bog); friend void bibliotekar::nyt_fagnr(bog *, char *); private: char titel[64]; char forfatter[64]; char fagnr[64]; }; bog::bog(char *titel, char *forfatter, char *fagnr) { strcpy(bog::titel, titel); strcpy(bog::forfatter, forfatter); strcpy(bog::fagnr, fagnr); } void bog::vis_bog(void) { cout << "Titel: " << titel << endl; cout << "Forfatter: " << forfatter << endl; cout << "Fagnr: " << fagnr << endl; } void bibliotekar::nyt_fagnr(bog * denne_bog, char *andet_fagnr) { strcpy(denne_bog->fagnr, andet_fagnr); } char *bibliotekar::skaf_fagnr(bog denne_bog) { static char fagnr[64]; strcpy(fagnr, denne_bog.fagnr); return (fagnr); } int main(void) { bog programmering("C++", "Jamsa", "P101"); bibliotekar bibliotek; programmering.vis_bog(); bibliotek.nyt_fagnr(&programmering, "P102"); programmering.vis_bog(); } -- Martin Ambuhl (mambuhl AT earthlink DOT net) Note: mambuhl AT tiac DOT net will soon be inactive