http://newdata.box.sk/bx/c/
Read everything at this site, and do all the activities. Then figure out what you want to achieve with a program, and try to do it.
Printable View
http://newdata.box.sk/bx/c/
Read everything at this site, and do all the activities. Then figure out what you want to achieve with a program, and try to do it.
Then don't work with windows yet - theres plenty more to C++ then pointers and structures. Once you get bored, try looking into the Standard Template Library.
SAMS BOOK! VOID MAIN! KILL THE LINK NOW BEFORE IT SPAWNS!Quote:
Originally posted by bennyandthejets
http://newdata.box.sk/bx/c/
Read everything at this site, and do all the activities. Then figure out what you want to achieve with a program, and try to do it.
I don't remember it using void main. Although, it has been a couple years now.
Quote:
Then don't work with windows yet
Best piece of advice yet. As for the STL I still have yet to really dive into it. I've used it but not extensively. There's always something else to explore in programming. That's why we love it so much.
You'll never master it all.
There's tons you can do in console mode...you definitely want to get used to as many topics as you can in console mode before you move to windows programmingQuote:
well I don't know what kind of program to write. I only know a little bit, enough for a console program. If it comes down to windows apps, I'm screwed
Well the part i looked at had it.....anyway its still a 21 days book - not many people here trust it, they arent very good on average.
EDIT: and just look at the first 3 lines of their hello world:
Code:#include <iostream.h>
int main(){
Thank you so much everyone for helping out. I have learned a LOT more than I expected tonight.
But, it is to everyone's disappointment that this post will come to its demise. It grew so fast! lol... Oh well, it's been fun! I'll work on programming stuff! Thanks for everything!
Ok, I just checked it. They use int main() religiously. And it's a very good book, it's how I learnt most of my c++.
Actually its rather refreshing this thread is ending - cuz it's making my head spin.
But I'm sure at least 50 or so more people will bump it.
It's been real. And to my fellow partners in crime...it's been fun guys.
Yay! OK DON'T POST NOW JAWIB.Quote:
Originally posted by MrDoomMaster
Thank you so much everyone for helping out. I have learned a LOT more than I expected tonight.
But, it is to everyone's disappointment that this post will come to its demise. It grew so fast! lol... Oh well, it's been fun! I'll work on programming stuff! Thanks for everything!
:D j/k .
*Tries to keep mouth shut*Quote:
Yay! OK DON'T POST NOW JAWIB.
Darn.
I'll be the first.Quote:
But I'm sure at least 50 or so more people will bump it.
Well, I got back in a little late, and though I tried to read over everything, some of that was a bit hard to follow. Anyways, this should be helpful on the difference between pointers and references.
Both do essentially the same thing. They point to a address in memory. A reference is a much 'safer' version of a pointer, however.
A reference:
- Must point to an already existing object
- Cannot be null
- Cannot be changed (that is, it cannot point to a different object later)
- As it creates no memory, never requires the user to cleanup
To create a reference, you use & after the type:
int a; // Create a new int
int& x = a; // Create a reference to a named x
A pointer:
- Can point to an existing object (using the addressof - & - operator if what you are assigning it to is not already a pointer), a newly allocated object (using 'new'), or an array of newly created objects (using 'new[]')
- Can be null (0)
- Can be changed
- Depending on how it is used, may require cleanup (using 'delete' or 'delete[]'), or may not, but you better be sure not to use something that you've already destroyed
Here are some pointer examples:
int a;
int* b = &a;
int* c = b;
int* d = new int;
int* e = new int[10];
delete d;
delete[] e;
Another difference in behavior comes with polymorphism. If you unsuccessfully dynamic_cast a pointer, you will have a null pointer returned. If you unsuccessfully dynamic_cast a reference, an exception will be thrown.
Also, some notes on const.
const type& - means that the object pointed to by the reference cannot be changed through the reference.
const type* - means the data pointed to by the pointer cannot be changed through the pointer, but you can change what data is pointed to
type* const - means that you cannot reassign the pointer, but you can change the data it points to
and...
const type* const - means the pointer cannot be reassigned, nor can you change the data it points to
Note that type& const is redundant
const type* = type const*
const type& = type const&
I asked earlier about decent compilers, anyone have any recommendations? I'm using Bloodshed Dev-C++ compiler, and the interface is amazing. I really like it. Any comments?
I need a post in this thread.Quote:
Originally posted by MrDoomMaster
I asked earlier about decent compilers, anyone have any recommendations? I'm using Bloodshed Dev-C++ compiler, and the interface is amazing. I really like it. Any comments?
If you like it; use it. If you can get your hands on a copy of MSVC though... it's very nice. Assuming you're coding on a windows machine.
GCC is probably the most standards compliant compiler that you're likely to find, but doesn't have an IDE. It's free, though. Unlike MSVC (assuming legal means).