Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[C++] Basics


Iscn
 Share

Recommended Posts

> Dev-Cpp is an IDE, not a compiler. The compiler that is being shipped with Dev-Cpp by default is MinGW, which is a port of GCC for Microsoft Windows.
>
> Yours faithfully
>
> S.J.R. van Schaik.

Sorry still new to this. Thanks for the clearification
Link to comment
Share on other sites

  • 2 weeks later...
Updated. Tutorial on variables added.

>! **Variables & Variable Identifiers :**
>! * First lets talk about variables.Lets say you have to take care of your monthly expenses. Now you can have rent expense, grocery, misc expense & others. And you have to keep track of all of them and how much they are every month.
* Example:
>! ```
>! Rent Expense = 100;
>! Grocery = 45
>! Misc Expense = 200
>! ```
>! * That is what a variable is pretty much, that bunch of numbers you have to keep track of.
* But consider that your computer can store millions of numbers like these at the same time and conduct sophisticated mathematical operations with them.
* Each variable needs an identifier that distinguishes it from the others.
* For example, in the previous code the variable identifiers were rent expense, grocery and Misc Expense.
* In real life we can call them that if we wanted but in programming world there are some set backs.
* We can call the variables any names we want to invent, as long as they are valid identifiers.
>! A variable identifier is used to let me say "brand' a variable. In C++ an identifier can be one or more letters, digits or underscore characters (_). You can't have a space or punctuation marks or symbols.
>! Ex:
>! ```
>! Proper Identifiers:
>! int newName;
>! int new;
>! int new_name;
>! int new123;
>! Bad Identifiers:
>! int new.name;
>! int 123wower;
>! int 123Meow;
>! They always have to begin with a letter not numbers!
>! You can begin with underscores too, but in some cases these may be reserved for compiler specific keywords or external identifiers.
>! ```
>! Another rule that you have to consider when inventing your own identifiers is that they cannot match any keyword of the C++ language nor your compiler's specific ones, which are _reserved keywords_.
>! Reserved Keywords:
>! ```
>! asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto, if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while
>! ```
>! There are others you can't use certain times.
>! ```
>! and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq
>! ```
>! Also know that your compiler might also have it's own reserved keywords.
>! **Very important:** The C++ language is a _"_case sensitive_"_ language. That means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters.
>! Example:
>! ```
RESULT
```
variable is not the same as the
>! ```
result
```
variable or the
>! ```
Result
```
variable.
>! These are three different variable identifiers.
>! And that is pretty much most of what you need to know for C++ Variables & Variable Identifiers.
>! Thank you for your time. By now you should have a good understanding of variables and how to write them right.
Link to comment
Share on other sites

Maybe go into the differant types of variables? How to make arrays? etc etc… Though i guess it teaches the super basics. Perhaps add that you cannot have spaces in variable names aswell. In your very first example though its not code you have spaced and some people may be confused. May have missed that bit as i only skimmed.

Also in your proper variable list you cant have int new. New is to make new memory and is a reserved keyword.

Thanks for sharing ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> Maybe go into the differant types of variables? How to make arrays? etc etc… Though i guess it teaches the super basics. Perhaps add that you cannot have spaces in variable names aswell. In your very first example though its not code you have spaced and some people may be confused. May have missed that bit as i only skimmed.
>
> Also in your proper variable list you cant have int new. New is to make new memory and is a reserved keyword.
>
> Thanks for sharing ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

Thanks for correcting me.

I was trying to proof read and i didn't make propers corrections.

Hard to correct your self.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...