C/C++ Guide to C++ Programming For Beginners

Click For Summary
The discussion focuses on a beginner's guide to C++ programming, emphasizing the importance of selecting a suitable integrated development environment (IDE), such as Bloodshed’s Dev-C++, for compiling and debugging code. Participants express appreciation for the tutorial's structure and suggest including deeper explanations of key concepts like conditional statements, iterative statements, and pointers. There is a request for clearer code examples to enhance understanding, particularly regarding function definitions and the use of header files. The conversation also touches on the potential for future tutorials on GUI toolkits and advanced topics. Overall, the thread serves as a collaborative platform for sharing insights and improving the learning experience in C++.
  • #31
I've been programming in C++ for around four to five years right now, and have to say I wish I had a tutorial like that when I started.

You might really want to teach Hungarian notation and standard naming conventions though.
Err, you know:

methods: methodNameHere()
constant: CONSTANT_HERE,
integer: iNum1, iNum2,
float: fNum1, fNum2

I say this because it really helps make the code neat and simple to read and understand.

Also, for anyone else interested, I would highly recommend the Deitel and Deitel book, C++ How to Program. Hands down one of the best books for beginners.

EDIT: Might also want to include a blurb on http://bloodshed.net, in my opinion the best free IDE for C++ there is. IDEs generally make the process of learning how to code from scratch much easier than working with commandline executed compilers. Plus, syntax hilighting is nice. :)
 
Last edited by a moderator:
Technology news on Phys.org
  • #32
Hungarian notation is an historical one. Everybody agrees these days that it is obsolate (see Java or .NET coding standards for example.

As for the book, just look at:
http://www.accu.org/cgi-bin/accu/rvout.cgi?from=0au_d&file=cp003204a

The conclusion: "Do not buy this book, and if someone tries to give you a copy decline, politely, then firmly."

If you want good books look for:
Bjarne Stroustrup, The C++ Langauge (the "c++ bible" by the creator of the language)
Effective C++ & More Effective C++, Scott Meyers (nice idioms)
Design Patterns, Gamma et. al (designing big applications)
Modern C++ Design, Andrei Alexandrescu (advanced _language_ usage, very heavy on templates)

In general, when you consider buying a book make a visit to www.accu.org to see at least one authorized opinion.
 
Last edited by a moderator:
  • #33
I was never a fan of Hungarian notation. However if you have to edit source code for a Win32 program you might come across it, so you should at least be aware of what it is.

I've never read the Deitel & Deitel book on C++ (I have their book on Java, it's OK), but to imply that a book for beginners is in the same class as an exhaustive C++ reference book (the one by Stroustrup) and an advanced text on OO design for software professionals and other advanced users is unreasonable. Those are good books but not suitable for those without substantial experience (either with C++ or OOP in general). And there's a lot to learn in C++.
 
Last edited:
  • #34
hatefilledmind said:
Those are good books but not suitable for those without substantial experience (either with C++ or OOP in general). And there's a lot to learn in C++.
I've read C++ How to Program from Deitel & Deitel, and it is excellent for beginners. It's not just learning C++ but learning programming concepts from the beginning in most structured way. The treatment of structured programming especially is great. I think it is useful for professionals as well who need to consolidate the messy knowledge they have in mind, and to write clearer programs.
I just would like to read a book for MFC with C++ but I'm not finding an appropriate one.
 
  • #35
rgrig said:
Design Patterns, Gamma et. al (designing big applications)
This is a classically important book of course, but if you ever read that book you'd understand that it is not for learning C++. How could a beginner understand what are patterns whithout knowing about design, or worse about programming basics.
 
  • #36
"Design patterns" is, as I said, for designing applications -- in any OO language.

For structured programming you are better of with Dijkstra's "Structured programming" book. His writing style is excelent.

Why exactly do you want to learn about MFC? It is old and a very good example of BAD library design. You would be much better off learning .NET class library or Java API.
 
  • #37
Well, MFC are the libraries that I have in my compiler, Microsoft Visual C++ 6.0. But I'd be willing to learn any other libraries for GUI in C++.
 
  • #39
I recommend the
Algorithms in C++ series by Robert Sedgewick
Code Complete (2nd Edition)
Code: The Hidden Langauge of Computer Hardware and Software - the book is on computer foundations and architecture, fair introduction to computer science

Ryan
 
  • #40
LogiX: your recommandations are better than mine!
From the same area: The Pragmatic Programmer, a book full of practical advices presented thru analogies that helps you remember.

One example: The Broken Window Theory. The advice: Never leave something broken (if you know it is broken). Story: A study of NY police with sociology&psychology researchers was intended to shed some light on when property is destroyed. They left an expensive car in an ill-famed neighborhood. A few weeks nothing happened. Then they broke a window. Within a few hours the car was completely destroyed and set on fire. Conclusion: Never leave something broken.
 
  • #41
ramollari said:
Well, MFC are the libraries that I have in my compiler, Microsoft Visual C++ 6.0. But I'd be willing to learn any other libraries for GUI in C++.

If you want to do GUI work outside of ms visual c++, I recommend using devcpp along with gtk and glade. Glade is just like the form builder you have in visual basic and it builds the code for you c/c++ project making use of GTK. The good thing is everything is free.
 
  • #42
cipher said:
If you want to do GUI work outside of ms visual c++, I recommend using devcpp along with gtk and glade. Glade is just like the form builder you have in visual basic and it builds the code for you c/c++ project making use of GTK. The good thing is everything is free.

As well as cross-platform.
 
Last edited:
  • #43
As well as cross-platform

The only thing that is not cross-platform is devcpp, which is only for windows.
 
  • #44
visual basic is cross platform?
 
  • #45
Alex said:
visual basic is cross platform?

I thought that cross-platform meant that something could work on multiple OSs or be compiled for multiple OSs. I didn't know that VB could do that.
 
  • #46
It's important to understand that Dev-C++ is not a compiler. Dev-C++ is an IDE (Intregrated Development Environment) that uses the MingW (windows port of GNU GCC) compiler.

I personally recommend using wxWidgets as a GUI API. It's build in a very OO manner which makes it easy to learn and work with. And, it is extremely portable across multiple platforms. http://www.wxwidgets.com

Visual Basic executables are not cross-platform.

Ryan
 
  • #47
cipher said:
I thought that cross-platform meant that something could work on multiple OSs or be compiled for multiple OSs. I didn't know that VB could do that.

What I meant was that you can write programs for many different platforms with c++, while Visual Basic limits you to Windows.
 
  • #48
Just use Delphi, it gets ride of this annoying ActiveX files. If you are making a windows app, use VB, if you need speed, use Delpi or CPP, if you need platform control, use Java, c#, C++, ect...

I recommend for anyone who is new to programing to start off with Visual Basic, then move on to something else.
 
  • #49
eNathan said:
I recommend for anyone who is new to programing to start off with Visual Basic, then move on to something else.
Let me say that Visual Basic is not the proper language to start with. It is too visual, too buggy, too inefficient, and too difficult to understand.
 
  • #50
Not to mention that it's not free!

I thought QBASIC was a beautiful language, is VB really that bad? (Of course, I had not yet heard of Pascal or C++ at that time in my life)
 
  • #51
Hurkyl said:
Not to mention that it's not free!

I thought QBASIC was a beautiful language, is VB really that bad? (Of course, I had not yet heard of Pascal or C++ at that time in my life)
It is all commercial: the language and the development environment. That is to the advantage of Microsoft.

Also by the way VB is little related with QBASIC. When I think of VB I think of 'drag and drop', not of programming.

VB is useful for prototyping and for RAD software development. But not for beginners who want to learn programming principles. C++ would be a good one.
 
  • #52
I started out with VB, and I agree. After I started programing in C++ I felt like I wasted a lot of time of VB. Oh well live and learn.
 
  • #53
ramollari said:
VB is useful for prototyping and for RAD software development. But not for beginners who want to learn programming principles. C++ would be a good one.

Python would be an even better one. Simple syntax, while teaching modern programming principles. Even after you move on to a different language, it's still great for scripting!
 
  • #54
my question is simple, i think, but it still killing me in class
i kinda gave up on learning new stuff, because i still have not been able to successfully run it,...nothing to do with errors(though i'll have those) but i don't know the specific way to run a program when u finish,...the ending part just does not make sense for me, pretty much because i don't know how to do it
 
  • #55
SqrachMasda said:
my question is simple, i think, but it still killing me in class
i kinda gave up on learning new stuff, because i still have not been able to successfully run it,...nothing to do with errors(though i'll have those) but i don't know the specific way to run a program when u finish,...the ending part just does not make sense for me, pretty much because i don't know how to do it

You're going to have to be a bit more specific, mate :frown:. What language are you using? What compiler? Can you post exactly the problem you're having and post the source of what you have so far?
 
  • #56
Hurkyl said:
Not to mention that it's not free!

I thought QBASIC was a beautiful language, is VB really that bad? (Of course, I had not yet heard of Pascal or C++ at that time in my life)
Oddly enough that's not entirely true. .net express
 
  • #57
i am creating two fileds a header file function.h with function wel() defined in it and a main file main.c which is calling wel() function define inside function.h. Hope this is enough.
function.h
public void wel()
{
printf("Hello Welcome !");
}

main.c

# "header.h"
int main(int argc, char *argv[])
{
wel();
return 0;
}
 
  • #58
people shouhld alwasy start with pascal =]
 
  • #59
Multidimensional arrays

dduardo said:
Please post your C++ questions or comments here for Tutorial 1.
I am having trouble getting my multidimensional array to do what I want it to do. Here is an exmple
of how I want this to look and how it will work.

row 1) Part Description | Part number //this is multidemsional array PD( row 1,columns 1-18 ), m array P#

row 2) Cam | 2110 // PD [1][0-4],Cam[1][0-4]

row 3) air filter | 1111 // PD [2][0-10],cam[2][0-4]
ect

My goal is on the first time the order function is entered to have row 1 and 2 display, the 2nd time the order function is entered rows 1,2,3 will display, the third rows 1,2,3,4 ect. Also the array will only display addresses not what it is supposed to. I know this is not an easy thing to do but I am not able to think of any other way to show all of the ordered items. Helllllllllllp plllllllllllllllease...

here is the code I have.

#include <iostream>
#include <iomanip>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

void partsorder(char order[]);
void list(char order[]);
int zz = 0;
const int ROWS = 50;
const int COLS = 50;
const int CAM = 20;

int main()
{
char shaft[CAM]="";

do
{
cout << "The cam number is 2110. The cam kit number is 2110k. Please enter\n"
<< "the approiate part number ";
cin.getline(shaft,CAM);
if (shaft[0] != 0) //if shaft is not null then goto
list(shaft);
}while(shaft[0] != 0);
}

void list(char order[])
{
if (zz == 0){
cout << " | Part Description |" << " Part # |\n ";
partsorder(order);
}
else {
partsorder(order);
}
}

void partsorder(char order[])
{
int num = 0, e = strlen(order);
num = atoi(order);
char c[CAM] = "Cam";
char ck[CAM] = "Cam kit";
char b,pd[ROWS][COLS];
zz++;

switch (num)
{
case 2110:
if (e == 4){
for(int y = 0; y < COLS; y++){
pd[zz][y]=c[y];

}
//strcpy(pd,c);
b = ' ';
//cout << "Please enter the quantity -->";
//cin >> q;
//price = 86 * q;
break;
}

else if (e == 5) {
for(int y = 0; y < COLS; y++){
pd[zz][y]=c[y];
}
//strcpy(pd,ck);
b = 'k';
//cout << "Please enter the quantity -->";
//cin >> q;
//price = 136 * q;
}
}
int x = 0;
for(int y = 0; y < COLS; y++){
cout << pd << endl;
for (x = 0; x <= zz; x++){
//cout << " | " << setw(16)<< setiosflags(ios::left) << pd [x][y]<< " | " << setw(5) << num << b << endl;
}
}
}
 
  • #60
no updates... :cry:
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 27 ·
Replies
27
Views
6K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
5
Views
7K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 13 ·
Replies
13
Views
6K