LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2005, 12:22 PM   #1
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Rep: Reputation: 30
New to C++ help with simple script


As the label says c++ is my first language other then php. im reading around through a book and to test a compiler i have a test scripts

#include<iostream>

int main()
{
std::count << "hello world\n";
return (0);
}

howerver when i run it with

CC -g otesting hello.cpp

i get the following error

Quote:
hello.cpp: in function 'int main()':
Quote:
hello.cpp:5 error: invalid operands of types '<unknown type>' and 'const char [13]' to binary 'operator<<'

Is this book maybe to old or is there something i need to configure?

thanks
 
Old 08-06-2005, 12:28 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
It should be std::cout, not count. Edit: I'm not sure if you should be using cc to compile C++, I thought that was just a C compiler. Try g++.

Last edited by Nylex; 08-06-2005 at 12:29 PM.
 
Old 08-06-2005, 12:53 PM   #3
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Original Poster
Rep: Reputation: 30
Thanks, yea reading through the book they let you know of all compilers but gives little to none on which one you should use. And that cout was my own doing ><


thanks =D

//edit

since i got you here mind if i add a few more questions?

Thought the book most work is done with some IDE is it ok that i just write my scripts in xemacs or is there a downside to this? if there is what type of ide should i use?

thanks

Last edited by Fredstar; 08-06-2005 at 01:03 PM.
 
Old 08-06-2005, 01:00 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
To compile hello.cpp into an executable called hello, you use "g++ hello.cpp -o hello". Which book is it that you have?
 
Old 08-06-2005, 01:06 PM   #5
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Original Poster
Rep: Reputation: 30
Practical C++ programming
 
Old 08-07-2005, 04:31 AM   #6
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally posted by Fredstar
Thought the book most work is done with some IDE is it ok that i just write my scripts in xemacs or is there a downside to this? if there is what type of ide should i use?
Use whatever editor/IDE you feel comfortable with. I'm happy with vi (the World's Best Editor) and the Korn shell history facility to develop my programs.
 
Old 08-07-2005, 04:45 AM   #7
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Hmm, I've not got "Practical C++ Programming" myself, but it seems to get mixed reviews (at least on Amazon).
 
Old 08-07-2005, 12:24 PM   #8
elyk1212
Member
 
Registered: Jan 2005
Location: Chandler, AZ USA
Distribution: Mandrake/Mandriva 10.2
Posts: 186

Rep: Reputation: 30
Practical C++ Is a great book, I Love all O'reilly books. But it seems a lot of programming books get mixed reviews depending on how much knowledge you have on the subject before reading the book. I had a good grasp of C++ and have been programming in C and similar languages e.g. Java for a few years before reading it, so mileage may vary.
I do like how it gives you little tasks to try, they are similar to the labs I had in my CSE classes a few years ago. They even touch on making your own data structures, essential to any good programmers tool box.
I find myself still picking up the book for reference and to reread certain areas.

By the way, I picked up mine for only about $5 with shipping on half.com. Good stuff.

Last edited by elyk1212; 08-07-2005 at 12:25 PM.
 
Old 08-08-2005, 10:59 AM   #9
cragwolf
Member
 
Registered: Jan 2004
Location: arse-end of the world
Distribution: Zenwalk 2.8
Posts: 73

Rep: Reputation: 15
Read up on GCC. There's a couple of nice chapters in "Running Linux" by Welsh et. al., and there is of course the manual.

By the way, you can get rid of the parentheses () around 0.

For beginner C++ books, if you have a little bit of programming knowledge (even if it's in unrelated languages), the following books are greatly recommended:

"Accelerated C++: Practical Programming By Example" by Andrew Koenig and Barbara E. Moo
"C++ Primer (4th edition)" by Stanley B. Lippman et. al.

If you have C knowledge, then you might try:

"Thinking in C++, Volume 1: Introduction to Standard C++ (2nd Edition)" by Bruce Eckel

And, of course, at some stage you must get the bible:

"The C++ Programming Language (3rd Edition)" by Bjarne Stroustrup ("da man")

Once you have passed the beginner's stage, and have entered the intermediate stage, you should try most of these books:

"C++ Common Knowledge: Essential Intermediate Programming" by Stephen C. Dewhurst
"C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" by Herb Sutter and Andrei Alexandrescu
"The C++ Standard Library: A Tutorial and Reference" by Nicolai M. Josuttis
"Modern C++ Design: Generic Programming and Design Patterns Applied" by Andrei Alexandrescu

I also recommend two series, Herb Sutter's "Exceptional" series:

"Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter
"More Exceptional C++" by Herb Sutter
"Exceptional C++ Style : 40 New Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter

and Scott Meyers' "Effective" series:

"Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition)" by Scott Meyers
"More Effective C++: 35 New Ways to Improve Your Programs and Designs" by Scott Meyers
"Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library" by Scott Meyers

As for programming tools, there's nothing wrong with using vi or emacs for editing and make for project management. But there's also nothing wrong with using Anjuta or KDevelop. Try them all out until you find something you're comfortable with.

Read, code, code, read, code, code, code, read, code, read, code, code, read, code, code ... and soon enough you will become smart thinkink C++ guru with evil Slavic accenkt!
 
Old 08-08-2005, 11:09 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
For a beginner, I recommend "Beginning ANSI C++: The Complete Language" by Ivor Horton. Personally, I find it very easy to follow and it doesn't require any previous programming experience.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
A very simple script roopunix Linux - Networking 3 05-28-2004 05:30 AM
A Simple Script fiod Linux - General 3 09-20-2003 08:56 PM
Simple Script fiod Linux - General 2 09-08-2003 03:03 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration