OT: C++ Question
Johnny Rosenberg
gurus.knugum at gmail.com
Fri Mar 13 17:57:13 UTC 2009
2009/3/12 H.S. <hs.samix at gmail.com>
> Karl Larsen wrote:
> >
> > karl at cheap-laptop:~/cplus$ g++ ex75.c
> > ex75.c: In function ‘int main()’:
> > ex75.c:24: error: no match for ‘operator<<’ in ‘std::cin << feet’
> > karl at cheap-laptop:~/cplus$
> >
> >
> >
> > As you can see the little c++ example from the book does not compile. I
> > added the (line 24) so you readers can see what line the g++ compiler
> > see's an error. I simply can't see the error and so need some help.
> >
> > Your welcome to try it on your Linux and I hope you do.
>
>
> statement should be:
> cn >> feet ...
>
> Moreover, your example you gave about does not compile anyway. I get:
> $> g++ -Wall foo.c -o foo
> foo.c: In function ‘int main()’:
> foo.c:19: error: ‘line’ was not declared in this scope
> foo.c:19: error: expected `)' before numeric constant
>
>
> Fix that. Try again.
He did fix it. He said above that ”I added the (line 24) so you readers can
see what line the g++ compiler see's an error”.
The line he's talking about looks like this:
”(line 24) cin<<feet<<inches; //Step2”
Of course it would have been better if he wrote it like this:
”cin<<feet<<inches; //Step2 (line 24) ”
Then it would be ignored by the compiler.
>
>
> Advice: use the usual c++ source code file extensions for c++ source
> code (cc, cpp, c++, etc.).
>
>
> I agree. Personally I prefer ”c++”.
By the way, Karl, and way off topic: ”CM” doesn't mean centimeters. ”cm”
does. I don't know what C means, but ”c” means ”centi”, ”m” means ”meter”
and ”M” means ”mega”. So one million meters = 1 Mm, but for some strange
reason people seem to rather say 1000 km, which indeed is the same thing but
still I wonder why not using Mm instead. And why use tons? 1 ton is exactly
the same as 1 Mg. Well, never mind…
J.R.
>
>
>
> --
>
> Please reply to this list only. I read this list on its corresponding
> newsgroup on gmane.org. Replies sent to my email address are just
> filtered to a folder in my mailbox and get periodically deleted without
> ever having been read.
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090313/1c7a0dc8/attachment.html>
More information about the ubuntu-users
mailing list