LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2003, 09:38 PM   #1
Canadian_2k2
Member
 
Registered: Oct 2002
Location: BC,Canada
Distribution: Debian
Posts: 92

Rep: Reputation: 15
C++


I am extremely newat porgramming with C and C++. I have done a few years with VB but want to learn C and C++
The only manuals and books are for M$ VS VC++
I first wanna learn console based C++, is there any good mans on it?
Also, what .h files do i include? iostream.h? How do i include that, I have my program
---------------------------------
#include <iostream.h>
int main() {

cout <<"Hello World";
return(0);
}

-------------
Then
[andrew01@newman Documents]$ gcc-3.0.4 hi.i
hi.i:2: syntax error at '#' token
hi.i:2: parse error before '<' token
[andrew01@newman Documents]$

What is wrong, where can i get a good man? what are the most usefull .h? Where is a good website?
Thanx
 
Old 02-11-2003, 10:07 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Re: C++

Quote:
Originally posted by Canadian_2k2
[andrew01@newman Documents]$ gcc-3.0.4 hi.i
hi.i:2: syntax error at '#' token
hi.i:2: parse error before '<' token
[andrew01@newman Documents]$
If you look at man gcc you'll find that
Code:
.i = .i    preprocessed C; compile, assemble
Traditionally one would give a C++ source
the extension .C, .cc or .cpp ... that should help
you with that problem :)

Also you might want to call g++ rather than gcc
As for C++ infos/tutorials ... grab google.com/linux
and feed it with tutorial C++ :)

Or look here :}


Cheers,
Tink

Last edited by Tinkster; 02-11-2003 at 10:11 PM.
 
Old 02-11-2003, 10:14 PM   #3
snow
LQ Newbie
 
Registered: Dec 2002
Distribution: RedHat 7.1
Posts: 22

Rep: Reputation: 15
yeah, there are plenty of online C/C++ forums-- I tend to look them up when I need them

*.h-- that's a header file; it tells the compiler to include code (found in the header) in your program-- that way you can call it

to include a header

# include <iostream.h>
# include <blah.h>

you have to know what commands you want to run in order to know what header you want-- you just need a good book for that-- the best books dont' really matter on platform

all of the basic stuff is the same on all platforms. if you're running a while loop on windows, it's going to be the same code on linux; it will be compiled differently on each machine, but the code will be the same. when you start getting into system calls, etc-- that's when it will start to matter (I"m not sure if the terminology is right on the call part-- I"m just a C++ newbie myself)

anways, just get a book. I tend to like Sam's cause I want concise explanations that explain functionality and dont just explain syntax-- but I"m not an instructor and I haven't seen anything. Just go sit in a bookstore for an hour or so

***of subject again: linux compile:

gcc -Wall source.c -o source
gcc -Wall hello.cpp -o hello

gcc is the compiler (gnu)

-Wall does all the warning level (let's you know when you've got syntax errors etc)

name of the source file

-o specifies the name of the file that it will be compiled to: otherwise it's a.out

there are tons of other options and "man gcc" and/or "gcc --help" will give you quite a few.

I'll shut up now. Good luck. (Oh, and if you're a linux newbie, make sure you've got all the development packages installed. Sometimes basic installs dont' do that. I dont' know exactly. I"m still a linux newbie)

Nate Snow
 
Old 02-11-2003, 10:40 PM   #4
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
This is a good online book on C++ < http://64.78.49.204/ >. Here is a website with C++ book reviews < www.accu.org > (see the book review section). In some ways you have to be careful with what C++ books you read because not all of them are ansi compliant. I would recommend 'C++ Primer 3rd edition'.
 
  


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




All times are GMT -5. The time now is 04:24 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration