Mail Archives: djgpp/1997/11/29/19:49:11
michael wrote:
>
> dear all c/ c++ programmers
> i have been having problem trying to compile this program
> for the last three days. the program has been wriiten correctly, there
> are no syntax errors.
not only are you a spammer, but you are also arrogant. see below.
[snip]
> // Specification file: plisting.h
> // declaring class phonelisting
> #ifndef PLISTING_H
> #define PLISTING_H
> #include <OURSTR.H>
first of all, do not capitalize the name of the header file. use
ourstr.h, gcc distinguishes between upper and lower case characters.
also, as a matter of convention, i prefer using
#include "ourstr.h"
for nonstandard headers.
> class phoneListing {
> public:
> phoneListing::phoneListing();
> phoneListing::phoneListing(string initLast, string initFirst,
string initNumber);
> void phoneListing::display();
> string phoneListing::lastName();
> string phoneListing::firstName();
[snip]
why not just do:
class phoneListing
{
public :
phoneListing();
phoneListing(string initLast, string initFirst, string initNumber);
etc ...
> private:
> string ln, fn pn; // the compiler keeps refering to this line, that
well, then look at that line: do you see a comma between fn and pn? is
that not a syntax error?
[snip]
> #include "plisting.cpp"
other people might disagree with me but i am allergic to including
source files.
[snip]
> cout << ' ' << phoneNumber() <, endl;
what does <, stand for. ooops, it is supposed to be << ... i guess that
is not a syntax error either.
[snip]
> #include "ourstr.cpp" // Add member function implementations
see above.
[i am bored ... snip snip ]
it took me about five minutes to get rid of the syntax errors, source
file inclusions etc and compile and link the test program using the
command line
gxx ourstr.cc plisting.cc ptest.cc -o ptest.exe -Wall
one advice: never assume everything you have done is correct.
ps: afaik, gcc has a bug related to the .cpp extension. it is safer to
use .cc for C++ source files.
--
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA
mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/
- Raw text -