www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/29/19:49:11

From: "A. Sinan Unur" <sinan DOT unur AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: why do i get this compiler error?
Date: Sat, 29 Nov 1997 18:17:57 -0500
Organization: Cornell University (http://www.cornell.edu/)
Lines: 90
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <3480A2A4.4B6F736D@cornell.edu>
References: <65q40m$6f3 AT camel12 DOT mindspring DOT com>
NNTP-Posting-Host: cu-dialup-0024.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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