Well week two's here and my instructor is just as hard to understand as last week. I don't even know if I have an American teacher or not this quarter. It makes me mad that the university hires these people knowing the students won't be able to understand them.
Setting up your program can be a little boring sometimes. There are a few lines of code that must go at the beginning and end of every program you write. We haven't learned what it means yet but with my experience I understand what it's doing.
This goes at the beginning of every program:
#include <iostream>
using namespace std
int main()
{
This goes at the end of every program:
return 0;
}
Anyway, one of the main functions of C++ is the console. Represented by cin or cout, the commands are used to control a program's input and output. The correct way to pronounce these words is "see-in" and "see-out".
In a typical program, you may see these console commands in code similar to the following:
cout << "Enter your age.\n";
cin >> user_age
Think of cout as your monitor; when you tell the console to output something it will usually be on your monitor. The arrows represent the flow of data, i.e. taking the string "Enter your age.\n" and sending it to the monitor to be displayed. The next line takes the user input from the keyboard and stores that value in the variable "user_age". Notice the arrows are pointing the other way; think of cin as your keyboard, the arrows then point from the keyboard to the variable.
Well there's plenty more to talk about but I have other classes to work on too so I'll be posting more from this lecture very soon.
P.S. I'll make a program out of the examples I used.
#include <iostream>
using namespace std
int main ()
{
int user_age, user_bday;
cout << "Enter your age. \n";
cin >> user_age;
cout << "you are " << user_age << " years old." << endl;
return 0;
}
If, for example, the user inputs 20 for user_age, the output will be "you are 20 years old."
Note: "\n" (newline) will cause a line break and the next output will be on a new line. It can also be replaced with the "<< endl" shown above.
God i hate C++. After C# I hope to never go back. I probably will, though. There are some things that C++ simply does better and faster. I just wish it had a prettier syntax.
ReplyDeleteI hear in some IDE's you can color code text so different kinds of syntax have different colors similar to how eclipse works with Java
ReplyDeletehaha i love c++, man
ReplyDelete:)
we have the same major! and we live in the same state! let's follow each other! <3
interesting stuff. hope to read more.
ReplyDeleteThanks for sharing this :)
ReplyDeletenice man, interesting wish i could understand more :)
ReplyDeleteand this is why im not a computer major haha
ReplyDeleteMight need to C++ to my repertoire. You should check out my blog too man. I just got it started.
ReplyDeleteI had a teacher I couldn't understand, he was portugese. Horrid class :/
ReplyDeleteLooking forward to more posts. I know how you feel on the whole teacher thing. I took java programming in college and they could barely speak English at all.
ReplyDeleteLove C+++
ReplyDeleteHoly moly the most code I know is AutoLisp and that confuses the shit out of me! GL with school!
ReplyDeleteThere's nothing like looking at C++ to make Python look even more majestic.
ReplyDeleteinteresting... do go on
ReplyDeletewell that reminds me on school when we had c++ and c#
ReplyDeletegood stuff
ReplyDeletei had a russian teacher for c++ . i learned nothing , read a good book and thats all you need.
ReplyDeleteI would like to go to school and learn about internet marketing, specifically SEO work. Do you have any suggestions on courses to take to get into that field?
ReplyDeletePretty sure it's using namespace std;
ReplyDeletedon't need a . character. It's not like C#, (in C# you do stuff like using System.Linq)
I like the way you designed your blog :)
ReplyDeleteNeat stuff, C++ is a great language, but it'll get trickier later. I still don't fully grasp the concept of pointers.
ReplyDeleteThis is really neat stuff you're doing
ReplyDelete