C++ newbie needs help with linked lists

S

Sonoman

Hi all:
I am trying to create an address book for a school project. So far I have a
good part of it done but I am stuck. I am getting some error that I would
not even know how to begin to explain. I have never seen these errors
before. They are illegal use of strings and missing parenthesis that I know
they are well placed. Would anyone care to look at my code to see if I can
get help to resolve these errors? I would like to be able to move on.

My source code can be found here:
http://www.cse.fau.edu/~fcarpio/

Thank you in advance.
 
S

Sonoman

One more question, what is the syntax to break up those very long lines that
I have?

Thanks in advance.
 
S

Sonoman

list.cpp
C:\Documents\ver8\list.cpp(24) : error C2447: missing function header
(old-style formal list?)
main.cpp
C:\Documents\ver8\main.cpp(23) : error C2275: 'string' : illegal use of this
type as an expression
c:\program files\microsoft visual studio\vc98\include\xstring(612) :
see declaration of 'string'
C:\Documents\ver8\main.cpp(23) : error C2146: syntax error : missing ')'
before identifier 'FN'
C:\Documents\ver8\main.cpp(23) : error C2059: syntax error : ')'
Error executing cl.exe.
 
O

osmium

Sonoman said:
I am trying to create an address book for a school project. So far I have a
good part of it done but I am stuck. I am getting some error that I would
not even know how to begin to explain. I have never seen these errors
before. They are illegal use of strings and missing parenthesis that I know
they are well placed. Would anyone care to look at my code to see if I can
get help to resolve these errors? I would like to be able to move on.

My source code can be found here:
http://www.cse.fau.edu/~fcarpio/

Give the name of the troublesome file, the first error message(roughly) and
the approximate line number.
 
J

Jon Bell

How do I break the line into two or even three lines?

Just do it. :) Newlines and blank spaces are equivalent everywhere in
C++ code, except inside a literal (quoted) string. So everywhere you have
(or could have had) a blank space, you can put a newline instead.

If you do have to deal with a long literal string, you can break it up
into two "adjacent" literal strings. For example, you can replace

"One two three four"

with

"One two "
"three four"
 
O

osmium

Sonoman said:
list.cpp
C:\Documents\ver8\list.cpp(24) : error C2447: missing function header
(old-style formal list?)
main.cpp
C:\Documents\ver8\main.cpp(23) : error C2275: 'string' : illegal use of this
type as an expression
c:\program files\microsoft visual studio\vc98\include\xstring(612) :
see declaration of 'string'
C:\Documents\ver8\main.cpp(23) : error C2146: syntax error : missing ')'
before identifier 'FN'
C:\Documents\ver8\main.cpp(23) : error C2059: syntax error : ')'
Error executing cl.exe.

I would use

#if 0
// suspect lines
#endif

to isolate suspect areas. When you think you have it fixed change the 0 to
a 1. If it is indeed fixed, take out the pre-processor code. I couldn't
get enough error location from what you provided to spot anything by
eyeball.

I really dislike your humungous parameter lists. A lot!
 
O

osmium

Sonoman said:
Me too! How do I break the line into two or even three lines?

I think you are thinking in physical terms and I am thinking in, sort of,
logical terms. I would create a new structure which had the 12 or so data
fields you have now. Then a function would receive one of these records as
a parameter. There might be a very slight speed penalty, but I think the
added clarity is worth it. IMO a list of parameters this long is kind of
mind numbing.
 
S

Sonoman

I did fix the ugly long lines and it worked just fine. Please help with the
original error.
 
L

lilburne

I'd say that the line in main():

l.save_record(string FN,...);

looks rather suspicious and likely to generate illegal use
of string and missing parentheses errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top