delorie.com/archives/browse.cgi | search |
Message-ID: | <39535192.2280CFA3@earthlink.net> |
From: | Martin Ambuhl <mambuhl AT earthlink DOT net> |
Organization: | Nocturnal Aviation |
X-Mailer: | Mozilla 4.73 [en] (Win95; U) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: string class? |
References: | <E135RSU-0003sl-00 AT scrabble DOT freeuk DOT net> |
Lines: | 61 |
Date: | Fri, 23 Jun 2000 12:00:23 GMT |
NNTP-Posting-Host: | 63.23.128.204 |
X-Complaints-To: | abuse AT earthlink DOT net |
X-Trace: | newsread1.prod.itd.earthlink.net 961761623 63.23.128.204 (Fri, 23 Jun 2000 05:00:23 PDT) |
NNTP-Posting-Date: | Fri, 23 Jun 2000 05:00:23 PDT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
markbatty AT freeuk DOT com wrote: > > I can see from the FAQ's there seems to be a problem with the string class. Can you double check this for me. You have confused the C header <string.h> with the C++ header <string>. See the corrected code, which compiles without error and runs properly, below: #include <iostream> /* mha - was <iostream.h> */ #include <string> /* mha - <string.h> is a C header, for which the corresponding C++ header is <cstring>. It has nothing to do with the C++ <string> functionality */ using namespace std; class play { public: play(const string & n); ~play(); void disp() const; private: string name; }; play::play(const string & n):name(n) { cout << "play ctor" << endl; } play::~play() { cout << "play dtor" << endl; } void play::disp() const { cout << name << endl; } int main() { play p1("Mark"); p1.disp(); return 0; } -- Martin Ambuhl mambuhl AT earthlink DOT net What one knows is, in youth, of little moment; they know enough who know how to learn. - Henry Adams A thick skin is a gift from God. - Konrad Adenauer
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |