![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
|
I think I'm having good teachers.. :p
![]() Anyway, now that I somehow understand the basic concept behind OOP which free sites, tutorials, manuals, etc. do you recomend to me? I've been browsing around and found some but since I'm learning the first language I don't know if these are any good for me. Also I found a site that said that I can get involved in some project on sourceforge and learn by doing there. But I think that would be getting me ahead of myself, 'cause first I should learn the baiscs... D'ya have any suggestions? |
|
|
|
|
|
#12 |
|
Programming Guru
![]() |
The basic idea is not to concentrate on each line of code, but what it's doing and how it's doing it instead. In the long run this will be MUCH more beneficial to your programming skillz.
__________________
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
|
Ok... So I've went to the tutorials forum and I've read this one which I found a bit confusing. So after reading some more someone suggested this site which I decided to take a look at. (I would really like if some one could give me an opinion about it)
Anyway. After the first lesson I've memorized enough stuff to do the very simple code that follows, but I'dd really like someone to take a look at the comments I made to see if I got it all straight. Feel free to correct me even at the more simple erros like "call that X instead of Y, 'cause it's more acurate..." and stuff like that. Anyway, really simple code follows: /* This is my first attempt at
some real programming! I'm using
the tutorial available from
http://www.cplusplus.com/ and this
what I've memorized from my first
lesson. (this of course, being
the comment block) */
//And this would be the comment line!
#include <iostream.h> //The # serves to pre-load stuff like, in this case the iostream "library"
int main() //int starts a function, in this case "main" which is the backbone of the program.
{//this starts to specify the code of a given function
cout << "testeeeee"; //cout serves to output something (in this case text) although I think it would porbably output other stuff like variables and the sorts...
return 0; //this signals the end of a function
}//and this marks the end of the code of the same function.I also take this chance to thank the help so far and appologize if something that I ask could be answered in google by some page I missed. Also please forgive any poor english but I'm Portuguease so I recon some errors come while speaking another language... ![]() EDIT: Some simple questions, BTW... why is there a "<<" in cout? and what exactly happens when the computer reads the "return 0" line? Also what does the iostream.h library do? |
|
|
|
|
|
#14 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
The << is a weird thingy that you don't need to know about. I barely understand it myself. All you need to know is that to print more than one thing, you just add it on the end:
cout << "Blah " << "More Blah" << endl; iostream.h is a library containing several input and output functions, so you don't need to write them yourself. cout is one of these - it's not part of the language, but part of iostream.h, or Input/Output Stream Header. Actually, if you want to use ANSI C++, which is the more up-to-date version, you should use #include <iostream> (without the .h). You then use std::cout instead of cout, as it is part of the Standard Library in this header file. Of course, most people find this annoying, so you can also add using namespace std; And finally, return 0. If you look above, you'll see it says int main(). The int part specifies this function returns an integer. As it is the main function, it returns it to the operating system, which can then parse the number and do something depending on it. But unless you're writing an application that interfaces with another in some way, I suggest leaving it as return 0. You can also use this statement before the end of the function to exit the program early. If any of this is incomprehensible, I apologise - it's nearly 4am. |
|
|
|
|
|
#15 | |
|
Hobbyist Programmer
|
So... I've tried the ACSII enhanced iostream (or whatever it is), but it seams not to be fond of the "using namespace std" bit...
The code (with little comments): #include <iostream> using namespace std
int main()
{
cout << "blah" << "more blah" << "and even more blah" endl; //this would make this version 2.0 of the example given by Ooble which includes one extra blah! ;)
/*so I seem to remember
how to use everything
so far, right?*/
return 0;
}
//WRONG!!! I'm getting errors... :(So this should make everything work, right? Wrong! I'm getting the following errors from the (bloodshed) compiler: Quote:
Anyway, I've fidled around with the code but with no apparent success on fixing it. The only way for me to get everything running just fine is if I remove the "using name space std" (and adding the std:: to the proper cout part) bit and the "endl" bit from the "cout" line. BTW, could you tell me what do STD and int (I know that int is integer, but I don't actually know what it is) stand for? It would make it easyer for me to memorize... I'm aiming at understanding programming instead of memorizing the strings of code... Although that I'll probably learn this in a future lesson, but it would make things easier now. Thanks again for the help... ![]() |
|
|
|
|
|
|
#16 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
I obviously didn't explain that bit clearly:
#include <iostream> using namespace std; And you need the << before endl as well. |
|
|
|
|
|
#17 |
|
Hobbyist Programmer
|
It works like a charm!
And thus our hero, broax, can proceed to the next level of enlightment (or however it is writen). But before he starts to learn of the wonders of variables, data types and constants, he would like to make two silly questions: 1st. is there any diference between cout << "something"; cout << "something else"; and cout << "something" << "something else";? If so what's would that diference be? And.... 2nd. can cout be used to output other type of data stream like, for instance, images or does it stand for something like carachter output? Anyway... I'll just take a long, long look at the next chapter of the tutorial and I'll post the results and/or doubts in here... ![]() BTW, a code that you probably never seen: #include <iostream>
using namespace std;
int main()
{
cout << "Billy, watch out..." << " HERE I COME! >D" << endl;
return 0;
}This is open source, you can use it on all your apps... lol ![]() |
|
|
|
|
|
#18 |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 4
![]() |
Most people start off these days with either C++ or Java
www.cplusplus.com has a decent tutorial (basics) |
|
|
|
|
|
#19 | ||
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
This is my first post in this thread so Hi is nice that you are learning to program. I love programming so I can assure you is a nice trip... It takes time to develop the logic behind it but after you get it... its all good... the answer to your questions ( as my knowledge goes ) are next:
Quote:
Quote:
I hope that the info helped you codetaino sorry for the errors my first language is spanish
__________________
"God bless u all" :) |
||
|
|
|
|
|
#20 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
cout, I believe, either stands for character output or console output. Either way, it only prints text to the console. When you get to variables, you'll see the real power of the function:
cout << "You are " << age << " years old." << endl; |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|