# Beginner information. . .



## Raistlfiren (Jul 14, 2004)

If I were starting out to try C++, what would you recommend to start out on? I have looked at multiple websites of information on C++, but nothing is really clicking. Is there an easier way to learn this, like by learning JAVA first or just buying a book from a store that may explain C++ better? Of course, this is all on my own time, and Im self teaching myself... Do you have any suggestions on starting out?
Rat


----------



## yto_daniel (Mar 25, 2005)

Understanding how java works will help you understand the Object Oriented concepts that C++ introduces over C. Learning JAVA may help you understand how C++ works better, but java is also a nicer language as far as available libraries and that sort of thing (in my opinion)

My recommended way to start learning C++ would be to simply have a project you want to program, you can sit down and try to learn it, but nothing helps you learn how to program then starting a project and learning how to make it work, using object oriented design.

Daniel - YourTechOnline.com technician
[email protected]_spam_yourtechonline.com (remove no_spam_)


----------



## Raistlfiren (Jul 14, 2004)

I do have a simple program I was looking at building. Like I said though, I don't know where to start at. I was looking at making a simple, but yet a basic program at the same time. I was looking at making my own picture slideshow program. Starting out at the begginning of course. First simply starting out by making a simpole crowser interface that will allow you to add pictures to. . . Though, I really don't know how to go about doing that... :/
Rat


----------



## yto_daniel (Mar 25, 2005)

Sounds like perhaps the best thing for you to do is some reading. 
Here is some C++ tutorials.
http://www.cprogramming.com/tutorial.html
And here is some Win32 API tutorial's, if your going to be building a browser type program, you will be learning the Win32 api.
http://www.winprog.org/tutorial/

Daniel - YourTechOnline.com technician
[email protected]_spam_yourtechonline.com (remove no_spam_)


----------



## Raistlfiren (Jul 14, 2004)

Okay,
Thanks for your info, I will read up on some C++. 
Rat


----------



## Shadow2531 (Apr 30, 2001)

First, download and install Mingw 3.4.2 so you can compile c++ programs
http://www.nuwen.net/mingw.html (follow directions on that page)

Copy the following code into your favorite text editor; making sure the last line in the file is blank.


```
#include <iostream>

using namespace std;

int main() {
    cout << "\n" << "Hello, world!" << endl;
}
```
save as hello.cpp to your desktop.

load up the command prompt and make sure the current directory is your desktop.

Type the following command and press enter.

g++ -Wall -Wextra hello.cpp -o hello

That will create hello.exe

Type hello and press enter. The program will run.

If you specify want OS you are using, we can give you some more specific directions.


----------



## Arcadion (Sep 2, 2004)

A good book to teach yourself C++ with is "C++ How to Program" by Deitel & Deitel, it's what I used when I was at high school and was the standard text for introductory C++ courses at my university. For what you're wanting to do I would suggest learning Visual Basic first, and take up C++ second--I learnt BASIC and VB before C++.


----------



## Raistlfiren (Jul 14, 2004)

I have figured out how to do that Shadow, though I mauy not know what the heck I am doing... hahahaha

So are there more than one visual basic program out there? I am guessing this, because when I look up information for Visual Basic it has a different interface from Microsoft Visual C++ 6. . . Is Microsoft Visual Basic different?
Rat


----------



## yto_daniel (Mar 25, 2005)

As far as I know, there is only one Visual Basic(Microsofts), Visual Basic is a completely different programming language. If you have Visual Studio 6 Then you'll have visual basic already.

Daniel - YourTechOnline.com technician
[email protected]_spam_yourtechonline.com (remove no_spam_)


----------



## Raistlfiren (Jul 14, 2004)

Microsoft Visual C++ is not the same, then? 
Rat


----------



## yto_daniel (Mar 25, 2005)

Microsoft Visual C++ and Microsft Visual Basic are totally different programming languages, Arcadian suggested it becuase Visual Basic is sometimes alot easier to understand for a beginning programmer.

Daniel - YourTechOnline.com technician
[email protected]_spam_yourtechonline.com (remove no_spam_)


----------



## Raistlfiren (Jul 14, 2004)

Oh I understand now. Two totally different languages... Man, so much stuff to choose from! Dang. . . Gosh, the question is what is the best way. . . I am so lost in this C++ stuff. 

I have been looking at some source code on making a basic calculator in C++, but this stuff isn not clicking as well as I thought it might click. Just don't really know where to start at. I know, you have to get the basics down first, but don't know what to do after I get the basics down... :/
Rat


----------



## TofuTheGreat (May 24, 2005)

The thing to realize is that programming languages are not a one-size-fits-all type of thing. Each language has its own strengths and weaknesses.

If I may ask some questions and make some suggestions?

First question, what is your familiarity with programming in general? Are you comfortable with program flow, logic, looping, etc.? If not then you should first read up on program and algorithm design before you delve in to specific languages.

Second question, what kind of goals do you have for your programs? Are you looking to create small utilities and applications for your own use and possibly freeware/shareware distribution?

Third, what kind of programs do you want to write? Small applications like graphics browsers, password managers, calculators, etc. are one thing. But programs that interact with the core of the operating system are a totally different bird.

Finally is your target platform strictly Windows or do you want to be able to port your programs to Unix/Linux, Mac, etc.?

Answering these questions will help to determine what program language(s) to learn. For instance Visual Basic will ONLY work on Windows platforms. It was designed by Microsoft specifically for Windows programming. Visual C++ is a "flavor" of C++ that happens to be geared heavily towards the Windows platform. Straight C++ (a.k.a. ANSI C++) is a "portable" language in that pure C++ programs can be modified to run on almost all OS platforms.

Visual Basic (VB) is definitely a good starting language to get used to objects, functions/subs, program flow and algorithms, etc. Much of the nitty-gritty programming work is done by the development environment (IDE). Instead of having to know how to code a button from scratch you just drop a button on the form. This lets you concentrate on the main logic of how your program will use the button. This makes taking the calculator project pretty simple in VB and a good choice.

I would also recommend that you learn more than one language. Some languages are simply better at doing things than another language. VB is a great tool for creating user interfaces and database applications while C++ is awesome for creating very fast programs as well as operating systems themselves. C++ is also used for creating programs that handle protocol communications (i.e. email, web browsers, ftp, etc.).

For instance you could write a .dll in C++ that handles TCP/IP communications. Then a VB program's interface is created to "wrap" the C++ .dll's functionality. So your graphics browser could be a VB interface that uses that .dll to upload the picture to a webserver.

Best of luck and keep asking the questions as that's the way to learn!

Christopher



Raistlfiren said:


> Oh I understand now. Two totally different languages... Man, so much stuff to choose from! Dang. . . Gosh, the question is what is the best way. . . I am so lost in this C++ stuff.
> 
> I have been looking at some source code on making a basic calculator in C++, but this stuff isn not clicking as well as I thought it might click. Just don't really know where to start at. I know, you have to get the basics down first, but don't know what to do after I get the basics down... :/
> Rat


s


----------



## Raistlfiren (Jul 14, 2004)

Thanks for all of that great information ToFu.

The first question I don't really know how to answer. I am not all that familiar with programming. I have done some HTML coding of a website, but that is about it. I have tryed looking into some C++, and have used Visual Basic C++.

The programs I wanted to make would be more for myself/freeware programs. I would like to be able to rely on myself to do things instead of relying on other companies. I was wanting to make my own things so I could optimize them and tweak them. So then I could make the program better and more how I like it. (More suitable for my needs)

The program I was looking at building was all sizes. I was looking at just building my own pi program, that I could run in the background of my server to calaculate pi. A program that I can customize to tell it how much cpu to only use, disc space, and etc....

The other program I was looking at making was my own slideshow picture maker. I believe this would be one of the bigger programs because I was looking at making a nice little interface with all types of different things to do with it. For example burn DVD slideshows, CD slideshows, exxecutable slideshows, and be able to customize my slideshows a whole heck of a lot more...

My target platform is any of them. I hope to be able to use my programs on any platforms, meaning linux, windows, and MAC. . .

I have checked out VB, but it looks a little bit more weird then just typing pretty much everything out in C++. I was just hoping to know and understand more of different programming languages so I can rely more on myself. Make a few programs that are suitable for me and other people... I am just kind of lost though in this whole C++ programming stuff. I look at the very first line and don't even understand #include<iostream.h> or #include<math.h>. I understand most of the bottom stuff, but the top just kind of confuses me. I was just looking at this calculator program... 
{ 
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); 
SetConsoleTextAttribute(hCon,color); 
} 
What in the heck... I understand a lot of the other middle stuff like case0,case1, case2, cout, cin, and all of that... The bottom code is just weird.... I found the calculator source from this site. http://www.cprogramming.com/cgi-bin/source/source.cgi?
action=Category&CID=8
Rat...


----------



## TofuTheGreat (May 24, 2005)

Raistlfiren said:


> The first question I don't really know how to answer. I am not all that familiar with programming. I have done some HTML coding of a website, but that is about it. I have tryed looking into some C++, and have used Visual Basic C++.


Just to clarify. C++ is one language and Visual Basic is another. Visual Basic C++ would be a mutant stepchild if it existed. 

Warning longish-novel-post follows. 

Now let's see if we can't help you out with the world of programming. First I would suggest a book called Simple Program Design. It'll introduce you to programming concepts. The "For Dummies" books can be good but who wants to have a book that's calling you a dummy? 

Now, on to some specific questions from your last post.


Raistlfiren said:


> I was looking at just building my own pi program, that I could run in the background of my server to calaculate pi. A program that I can customize to tell it how much cpu to only use, disc space, and etc....


Wow. On the surface this seems like it would be a simple program but it's actually very, very tough. I would actually avoid this one like the plague until you've gotten your feet a bit wetter. The problem is the infinite nature of pi itself. You get into problems with data types, precision, resource allocation (i.e. memory, etc.). You could quickly come up with a program that would crash your system in a second. Universities have cluster farms trying to calculate pi.

_"It is interesting to note that even today pi cannot be calculated preciselythere are no two whole numbers that can make a ratio equal to pi. Mathematicians find a closer approximation every yearin 2002, for example, experts at *the University of Tokyo Information Technology Center determined the value of pi to over one trillion decimal places."*Article on Nova _​


Raistlfiren said:


> The other program I was looking at making was my own slideshow picture maker.


This is an ambitious starting project but not outside the realm of possiblity. You could use the versioning approach with each major version being the addition of a new feature. So version 1 would be a simple interface for displaying the images. Subsequent versions would be the add-ons you described.


Raistlfiren said:


> I have checked out VB, but it looks a little bit more weird then just typing pretty much everything out in C++. I was just hoping to know and understand more of different programming languages so I can rely more on myself. Make a few programs that are suitable for me and other people... I am just kind of lost though in this whole C++ programming stuff. I look at the very first line and don't even understand #include<iostream.h> or #include<math.h>. I understand most of the bottom stuff, but the top just kind of confuses me.


This may be the best example of why you should look into VB first. To be truthful my first language was C and VB was about my 5th or 6th. But let's explain the "#include" statements. The statements are used to bring in pre-coded "libraries" into your program. Basically a library is a set of related functions. You bring them into your program so that you don't have to write them from scratch yourself (kind of a "don't reinvent the wheel" thing). Most every higher level language has this "include" functionality. For example in COBOL thier known as "copybooks" and you use the "copy" keyword.

So the "math.h" library contains all kinds of math functions (from basic through some trig if memory serves). The "iostream.h" library contains functions for I/O streaming to the console and I think even to the LPT1 port. Basically it handles writing things to the screen. You make calls to the functions in those libraries passing arguements (parameters) as needed.

The neat thing is that you can create your own library files so that you can reuse code without having to type it from scratch each time. Any function that could be repeated in multiple programs is a candidate for including in a library. This is a big time saver in larger programs.

You can also take a pre-defined library and customize it to your own needs (like stripping out sections you don't need to make your program smaller and faster). Just don't EVER overwrite the standard libraries. You'll be hosed if you do.


Raistlfiren said:


> What in the heck... I understand a lot of the other middle stuff like case0,case1, case2, cout, cin, and all of that... The bottom code is just weird.... I found the calculator source from this site.


The problem you appear to be running into is the syntax of the language. Each language has it's own syntax and some are easier to read than others. Your above statement alone is probably enough for me to point you towards VB as your first language. Couple this with either the calculator or graphics display program and VB is even more appealing as your first language.

VB will allow you to seperate the programming of the interface components from the interface functionality. Coding a window from scratch is a major pain in the tush if you don't know what you need to do. It'll also confuse the heck out of a beginner as you need to know about handles, threads, interupts, etc.. It's easier just to let a visual language (Visual Basic, Visual C++, Delphi, etc) handle it for you. The same goes for the components like buttons, labels, text boxes, etc. This way you can concentrate on the core functionality of the program itself.

I would also suggest VB.Net instead of VB6. VB6 is simpler in many respects but eventually you'll end up going to .Net anyway and then you've got another learning curve to overcome. There is even a learning edition of Visual Basic.Net available online (~$80 US). I think Microsoft was even offering one for download? I'll see if I can find it again.

May I suggest that we concentrate first on the calculator program instead of the graphics browser? This will get your feet wet with the concepts of objects, functions, parameters, and most importantly program flow. Plus the calculator can quickly expand into other projects like a check-book tracker, home expense manager, stock manager, etc. Once you're familiar with the programming approaches then you'll be ready to move on to more ambitious programs. Think of it as the walk-before-you-run approach.

I'll be happy to help you along with the project.

Christopher


----------



## Raistlfiren (Jul 14, 2004)

Hi and thanks for all of the help you have offered. The list of information you have provided for me is great.

Ahhh, I thought Visual Basic was a stepping stone only to C++ programming. So Visual Basic is just a step to introduce programming to beginners and teach them some of the basic functions of programming.

I will have to check out the book some time when I stop over at a book store. The thing is I checked out and bought _C++ Programming for Dummies_, but it didn't help out that much. I'm a special case I guess, if I don't understand that... hahaha. I have also tryed a few other books out over C++ Programming also. I have also printed and looked at a lot of this tutorial tutorial webpage also: http://www.cplusplus.com/doc/tutorial/index.html The programming language just isn't clicking. . .



> Wow. On the surface this seems like it would be a simple program but it's actually very, very tough. I would actually avoid this one like the plague until you've gotten your feet a bit wetter. . .


I guess you are right about that. It could get pretty technical trying to make a program like that, because pi goes on forever. I thought it might be some what of a simple program, because I just wanted to check out how far I could calculate pi on my server.

So the #include <math> or whatever you want to put in the brackets can be interchangeable. So the #include is telling the program to look at the libraries within the program... So you make a library and then you tell the program to do what the library does, and then the #include<iostream.h> is pretty much telling the program to print the information on the screen like you said. . .

I will have to take a look at Visual Basic .NET. Never heard of it, but I will have to check it out sometime.

Anyway to your question of concetrating more of the calculator program, it does not matter to me. I thanks you a lot for providing all the information to me once again. It has been very helpful.
Thanks,
Rat


----------



## TofuTheGreat (May 24, 2005)

Forgive for taking these out of order but they feed into one another better this way.



Raistlfiren said:


> So the #include <math> or whatever you want to put in the brackets can be interchangeable. So the #include is telling the program to look at the libraries within the program... So you make a library and then you tell the program to do what the library does, and then the #include<iostream.h> is pretty much telling the program to print the information on the screen like you said. . .


The part between the angle brackets is literally the name of a seperate text file. That file contains more source code (source code is what you write and then it gets compiled into your executable program or .dll file).

If you look at the calculator example that you downloaded before you'll see the "global.h" file. You can literally open this up in Notepad (or any text editor) and see what functions are in there. There's even more includes stuck in there!

The iostream.h file itself doesn't tell the computer what to write on the screen. Rather it's the library of input and output functions that you can then use in your programs. You don't _have_ to use iostream.h in your program if you don't want to. But then you'd have to hand-code your out i/o functions yourself (not fun).

Once you have a C++ compiler installed on your PC you can open the iostream file itself and actually see all the different input and output functions it will provide for you. You can do that with any library file. This helps you to know what functions are predefined so you can determine what you need to write vs. what's already been written.

There is a good explaination of header files here. It uses the iostream.h for the explaination. It might make more sense after reading that.



Raistlfiren said:


> I have also printed and looked at a lot of this tutorial tutorial webpage also: http://www.cplusplus.com/doc/tutorial/index.html The programming language just isn't clicking. . .


C++ has a pretty steep learning curve for beginners. You have to learn:
- The reserved words (I think there's only 48)
- The core C++ header files (iostream.h, math.h, etc.) and their contents. BTW, header files are also know as #includes and/or preprocessor directives.
- The syntax rules of the language. This includes how to define functions (including prototyping), how to call functions and how to return values from functions.
- More advanced techniques like arrays and pointers (you don't want to go there yet).
- How to design your program and any objects it may need
- Algorithmic logic
- data types
- etc., etc., etc.

Don't feel bad though. Everyone I know had their struggles with C++ at first. But if you stick with it you'll eventually have an "AHA!" moment where things suddenly start to "click" and make sense.

If you are really intent on learning C++ you should take that calculator example and dissect it completely. I've attached the one that I'm looking at in case you've got a different one.

Learn what each and every part of that program does before you try to modify it. Then you can figure out what other things you want it to do and learn how to do them.

Christopher


----------



## Raistlfiren (Jul 14, 2004)

Shoot, I am really sorry about not responding in forever. I have had a lot of things to do and I never got any email reply over the topic! Sorry... Sorry...

Thanks for your time in putting into typing all of this out and all. Let me read a little bit more of this before I reply back. I will reply back promptly this time.
Sorry again,
Rat


----------



## Jeffyboy (Mar 3, 2005)

I agree with the visual languages... if you are interested in C++... try using Borlands C++Builder. It's very visual ;-) I use Delphi myself and I am very pleased with it. Of course, there is a learning curve with everything. C++Builder will also compile for linux too.


----------



## Raistlfiren (Jul 14, 2004)

Woh... Long time... I believe things are becoming a little bit more clearer on how to do C++ programming. I got a few other books and stuff to help out. I think it is slowly seeping into my mind. 

I read your information about the headers and stuff... I believe I understand all of it a little better. Thanks for your time... I believe I can handle it from here.
Thanks again,
Rat


----------

