Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,047 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,550 people online right now. Registration is fast and FREE... Join Now!




Learning C++ from scratch

 
Reply to this topicStart new topic

Learning C++ from scratch, I would like to start learning c++ from scratch, where would I start.

alakazamm
17 Jul, 2008 - 06:31 AM
Post #1

New D.I.C Head
*

Joined: 17 Jul, 2008
Posts: 3

Hey people,

I am looking to learn C++, I have no prior knowledge of any other language. I've tried using the 'Learn C++ in 21 Days' book which is on the internet but it does not really explain anything. I have made the 'Hello World' program but I cannot compile it because I always get errors.

Here is the code I use:
CODE
#include <iostream>

int main();
int main()
{
cout << "Hello World!\n";
return 0;
}


The guide doesn't specify any particular software or compiler it just says I need a raw text editor (notepad) and some sort of compiler. I downloaded 'Cygwin' and use it to compile but I always get the following messages:

hello.cpp: In function 'int main()':
hello.cpp:6: error: 'cout' undeclared (first use of this function)
hello.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)

The code I used is copy and pasted straight from the guide but it still doesn't work. If anyone could explain what is going wrong I would really appreciate it. I am more annoyed at the fact that following the guide word for word doesn't work and I would be even more happy if someone could point me in the right direction or show me a working guide which can help me get started on learning this code.
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Learning C++ From Scratch
17 Jul, 2008 - 06:39 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
If you copied that from a specific book, I would suggest you get another book. this code will not compile on any compiler. It should read:
CODE

#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!\n";
return 0;
}


http://www.cplusplus.com/doc/tutorial/


User is online!Profile CardPM
+Quote Post

KYA
RE: Learning C++ From Scratch
17 Jul, 2008 - 07:14 AM
Post #3

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 4,775



Thanked: 91 times
Dream Kudos: 1200
My Contributions
I don't know what version you have of that book; I really enjoy the C++ 21 days one that I own. Sidenote, you don't need to declare main()'s prototype like other functions.
User is online!Profile CardPM
+Quote Post

markhazlett9
RE: Learning C++ From Scratch
17 Jul, 2008 - 07:25 AM
Post #4

D.I.C Head
**

Joined: 12 Jul, 2008
Posts: 160



Thanked: 10 times
My Contributions
I'm just in the process of learning C++ for the first time too. I have a little bit of prior knowledge on BASIC but that's about it. The book that i'm finding the best for learning is "Starting out with C++ from control structures through objects" sixth edition by Tony Gaddis.... It's 1400 pages but if you can get through it it's really helpful. Hope this helps
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 05:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month