delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/23/07:17:36

From: markbatty AT freeuk DOT com
Date: Fri, 23 Jun 2000 12:17:14 z (BST)
To: djgpp AT delorie DOT com
Subject: string class?
X-Mailer: AtDot 2.0.1
X-URL: http://www.freeuk.net/
Message-Id: <E135RSU-0003sl-00@scrabble.freeuk.net>
Reply-To: djgpp AT delorie DOT com

I can see from the FAQ's there seems to be a problem with the string class.  Can you double check this for me.

I am re-learning C++ as I did a course about three years ago but never really used it - so the skeleton below may be wrong!

The following is a skeleton program (to highlight the error, nothing else) followed by the command line and the output.

Is there something I can do to build programs using the string class, if not do you know when there will version available to support strings?

Thanks.

Mark.


tplay.cpp
---------
#include <iostream.h>                
#include "play.hpp"

int main()
{                                   
	play p1( "Mark" );

	p1.disp();

	return 0;
}


play.hpp
--------
#include <string.h>

class play
{
public:
	play( const string & n );
	~play();
	void disp() const;
private:
	string name;
};


play.cpp
--------
#include <iostream.h>
#include "play.hpp"

play::play( const string & n ) : name( n )
{
	cout << "play ctor" << endl;
}

play::~play()
{
	cout << "play dtor" << endl;
}

void play::disp() const
{
	cout << name << endl;
}


command line
------------
C:\mjb\prg\cpp\sgl>djredir -o out.txt -eo gxx -v -Wall play.cpp tplay.cpp -o tpl
ay.exe


output
------
Reading specs from c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/specs
gcc version 2.95.2 19991024 (release)
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/cpp.exe -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dunix -Di386 -DGO32 -DDJGPP=2 -DMSDOS -D__unix__ -D__i386__ -D__GO32__ -D__DJGPP__=2 -D__MSDOS__ -D__unix -D__i386 -D__GO32 -D__DJGPP=2 -D__MSDOS -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentium__ -imacros c:/mjb/djgpp/lib/../include/sys/version.h -remap play.cpp c:/mjb/djgpp/tmp\ccR4iS6H.ii
GNU CPP version 2.95.2 19991024 (release) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 c:/mjb/djgpp/lang/cxx
 c:/mjb/djgpp/include
 c:/mjb/djgpp/lang/cxx
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/include
 c:/mjb/djgpp/include
End of search list.
The following default directories have been omitted from the search path:
 $DJDIR/lib/gcc-lib/djgpp/2.952/../../../../djgpp/include
End of omitted list.
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/cc1plus.exe c:/mjb/djgpp/tmp\ccR4iS6H.ii -quiet -dumpbase play.cc -Wall -version -o c:/mjb/djgpp/tmp\ccgyWSam.s
GNU C++ version 2.95.2 19991024 (release) (djgpp) compiled by GNU C version 2.95.2 19991024 (release).
In file included from play.cpp:2:
play.hpp:6: parse error before `&'
play.hpp:10: syntax error before `;'
play.cpp:4: parse error before `&'
play.cpp: In method `void play::disp() const':
play.cpp:16: `name' undeclared (first use this function)
play.cpp:16: (Each undeclared identifier is reported only once
play.cpp:16: for each function it appears in.)
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/cpp.exe -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dunix -Di386 -DGO32 -DDJGPP=2 -DMSDOS -D__unix__ -D__i386__ -D__GO32__ -D__DJGPP__=2 -D__MSDOS__ -D__unix -D__i386 -D__GO32 -D__DJGPP=2 -D__MSDOS -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentium__ -imacros c:/mjb/djgpp/lib/../include/sys/version.h -remap tplay.cpp c:/mjb/djgpp/tmp\ccR4iS6H.ii
GNU CPP version 2.95.2 19991024 (release) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 c:/mjb/djgpp/lang/cxx
 c:/mjb/djgpp/include
 c:/mjb/djgpp/lang/cxx
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/include
 c:/mjb/djgpp/include
End of search list.
The following default directories have been omitted from the search path:
 $DJDIR/lib/gcc-lib/djgpp/2.952/../../../../djgpp/include
End of omitted list.
 c:/mjb/djgpp/lib/gcc-lib/djgpp/2.952/cc1plus.exe c:/mjb/djgpp/tmp\ccR4iS6H.ii -quiet -dumpbase tplay.cc -Wall -version -o c:/mjb/djgpp/tmp\ccgyWSam.s
GNU C++ version 2.95.2 19991024 (release) (djgpp) compiled by GNU C version 2.95.2 19991024 (release).
In file included from tplay.cpp:2:
play.hpp:6: parse error before `&'
play.hpp:10: syntax error before `;'
tplay.cpp: In function `int main()':
tplay.cpp:7: no matching function for call to `play::play (const char[5])'
play.hpp:11: candidates are: play::play(const play &)
play.hpp:11:                 play::play()




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019