• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Learn it Yourself: C++ Course

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.
Hi guys, very late to the party, and this looked like an okay thread to ask. I just now started C++ and am trying to do my own hello world program. I am using Dev-C++. So, I compile with no errors, and as it runs it, the box that I believe would have the "hello world" in it shows up but instantly closes before I can read it.

Can anyone help a mega noob here?

This is what I have:

#include <iostream>

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

Edit:If I try to just "Run" the file instead of compile and run, I get the "source file not compiled error". Not sure if that is helpful or not :)

Put in a pause just before the
Code:
return 0;
to keep it alive until you hit enter or something.

In windows a common way to do this is with:
Code:
 system("pause");
 
WoW! what a great thread and I probobly would have never noticed it if it hadn't been posted on recently. Imma bookmark this and read it over a few times seeing as It will give me a jump start on what Im already taking in school. :)
 
Thanks, Trombe! Worked perfectly. I wonder if it's because I'm using Vista or something? I'm beginning to second guess this book I bought as a guide.

Also, for those of you that are quite familiar with C++, is this guide a very good one for someone that's absolutely new to programming, or should I look for an even lower level guide?
 
Hey guys a couple more basic questions.

How should I be saving my practice source files? In a project, or in single form? Is it okay to create a new folder in My Documents for practice C++ things? Right now, all of my stuff is saved in Computer > C: > Dev-Cpp, in which there are a bunch of folders and files, which are installed from the program. I just want to sure when I try to compile and run something from another folder, it will do it okay.

Also, please help me clarify:

A source file is a single "page" with all of your code on it
A project is a grouping of a few or many source files within it, that run off of/with each other.

And Trombe, for that pause command, am I going to have to do that every time I want a line to pause? Because in my book it never mentioned pausing, and I'm worried it might cause me to slip later.
 
Last edited:
Hello, i realize that this thread is a little dated but i am very interested in learning C++. I am broke as a joke so a book is out of the question the only place my money is going is into my new rig that i will hope to be building very soon.

MSI NF980 mobo
AMD Phenom II X4 965
CORSAIR CMPSU-850HX 850W
MSI N260GTX
CORSAIR XMS3 8GB

anyhow untill i get some funding for that I am willing to devote a significant portion of my time learning and understanding C++. I appreciate all of your help so far. Unfortunately I am stuck I am at Lesson 4 Our First Program (Day 2) at the end of this post Frodo states:

Close your workspace and open a new one called IOProblems. You will put

Problems

1. Create a program that asks the user to pick a number. When the user responds, tell the user that this is also your favorite number.

I have tried for about two full days to make this program but I have no other programming experience and I would really like continue learning C++ I would really appreciate some input thank you guys for the thread.

Ps. I am using devcpp-4.9.9.2
 
Do you have any code written yet, and, if so, what error are you seeing? Basically, you are probably looking for somthing like:

Code:
int userval = 0;
std::cout << "Pick a number";
std::cin >> userval;
std::cout << "Really? " + userval + " is my favorite number, too!";
 
Hello, i realize that this thread is a little dated but i am very interested in learning C++. I am broke as a joke so a book is out of the question the only place my money is going is into my new rig that i will hope to be building very soon.

If you are broke Stanford offers free classes online to learn programming. I am finishing up the first class now and they are top notch. The first one is called programming methodology and the class uses Java. The second class uses C++ and is called programing abstractions.

The one thing is you can watch all the lectures free online or download them. However, I found it very helpful to buy the book. But if you are that broke you might have to do without.

http://see.stanford.edu/see/courses.aspx

These are the intro computer science classes at Stanford. Start with CS106A and then move to CS106B.
 
Thank the both of you guys very much the code you provided me helped me get thru that issue and I think I will be following the stanford courses provided online from now on. I will also be visiting this fourm much more frequently thank you for the help.
 
Thank the both of you guys very much the code you provided me helped me get thru that issue and I think I will be following the stanford courses provided online from now on. I will also be visiting this fourm much more frequently thank you for the help.

might i suggest going with the tx which is non modular and a bit cheaper as well as the 955 be since while the core matures, it most likely will have better yields for better overclocking.

for small programs like this i could probably program on pentium 1.( i found one)

after you get some concepts down you can look for source code online and follow what people have done.(i don't even know c++ but if I could get some of the terms down i'd probably be able to make a few simple things)
 
I know this thread is really old - but this beginner book from Sam's publishing helped me. All I knew starting was HTML and some JavaScript.

C++ in 24 Hours

http://www.informit.com/store/c-plus-plus-in-24-hours-sams-teach-yourself-9780672337468

It has the examples available to download online. The book has a few code typos like all the rest of the books I have but you can figure them all out by asking on forums etc.

The 24 Hours biz a bit of a stretch. More like each chapter is 24 hours!

After doing this book over and trying to write code I moved over the NetBeans and the NetBeans IDE has a C++ IDE built in. So next up is to return to that and try C++ again.
 
fun with arrays

Lesson 7: Arrays (DAY 4)

How do we get a string if there is no string data type? The answer lies with arrays. A string is simply an array of characters. Defining an array is simple:

Here's a fun array trick for math problems. It is easy to write code if all of your answers are metric using decimal system - bt what if you want to display fractions?

I made a page for myself to practice common-denominator-math problems. I needed to display random numbers with ½ or ¾ etc. from half to sixty-fourths to show up, two at a time so I could add them. I didn't need the sum, just lots random numbers.

Using an image array I made my fractions as art images and just used whole numbers in the same font also as art images. The fractions I had appear to the right of the whole number. Very fun to code and it looked good at the end. (domain expired so I no longer have the page up)
 
I really need to learn C++ well so it can help me with Unreal Engine 5 game development. Would be cool if there are still people active in here that have the skills for C++.
 
Back