LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   C++ (https://www.linuxquestions.org/questions/linux-software-2/c-45015/)

Canadian_2k2 02-11-2003 08:38 PM

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

Tinkster 02-11-2003 09:07 PM

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

snow 02-11-2003 09:14 PM

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

GtkUser 02-11-2003 09:40 PM

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'.


All times are GMT -5. The time now is 08:05 PM.