 |
|
08-16-2007
|
#1 (permalink)
|
|
Creating
|
Not Ranked
:
+0 / -0
0 score
Finally learning C++!
Been around programmers for years, yet never actually got to work with them. Yes, I don't know one bit about computer programming. I've always wanted to know how to write programs, but I've never had the guts to go on the apparently difficult and gruelling path to become a programmer.
Things turned dark and cold when I got to Half-Life map editing. I knew how to make wonderful environments, and got to explore world I created. But the world were horribly empty, or simple repeats of the same things I had created only days back.  I had the source code right under my nose, but didn't have one bit of knowledge about how to use the wonderful tools.
But now, everything's gonna change. After coming to my new college, I was introduced to a course 'EC-101A'. Instantly I knew that I was where I always wanted to be. I would get to learn C++ in my very first semester, and possibly java by the second...
So here I am, setting up my base camp, ready to build my bones. I hope others like me will join me in my quest, and those who already have undergone it will assist...
I begin tomorrow...
Till then, the compiler I use will be 'Dev-C++ 4.9.9.2', available from here.
----------------
ronthepon, capitals avoided.
And don't ask me why.
|
|
08-16-2007
|
#2 (permalink)
|
|
Hypographer
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
Good luck mate. Maybe you can write some stuff for Hypography eventually? 
----------------
Your Friendly Neighborhood Administrator
Want to lose the advertisements? Become a Sponsor!
Join our Facebook group or follow us on Twitter
Science is not only compatible with spirituality; it is a profound source of spirituality.
- Carl Sagan
|
|
08-16-2007
|
#3 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
Why do you use C++ on hypography?
Ronthepon I'm happy to help when you need it, but I won't guarantee I know it...
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
|
|
08-16-2007
|
#4 (permalink)
|
|
Hypographer
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
Quote:
Originally Posted by sanctus
Why do you use C++ on hypography?
|
Hypography is all PHP and ColdFusion...but ColdFusion is built on Java and can use compontents written in C++.
...but we're probably purely PHP by the time ronthepon masters Java. 
----------------
Your Friendly Neighborhood Administrator
Want to lose the advertisements? Become a Sponsor!
Join our Facebook group or follow us on Twitter
Science is not only compatible with spirituality; it is a profound source of spirituality.
- Carl Sagan
|
|
08-16-2007
|
#5 (permalink)
|
|
Dedicated Smart-ass
Location: Just before 0xAA55
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
lol it needs to be PHP, CF is a hogg and there is really no advantage of using it over PHP anymore
if you wanna forward me the CF code, i can most definitely find time to start looking into changing it to PHP...
Granted that i dont know CF, but then again, that didnt stop me this morning from learning VBScript...
Rod, you'll pick it up, its a weird language to learn, but trust me unless you go assembly, after you know C++ you will have no problems learning new languages. And after you know a few, a new language is a matter of reading a book, and 2 weeks later you are programming in that language almost as well as a guy who has been learning it for 3-4 years. Trust me, been there with Python, Perl, Bash, Boe-Bot basic just to name a few....
----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.
Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.
Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

|
|
08-17-2007
|
#6 (permalink)
|
|
Creating
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
Thankyouthankyou! I've had my first class today, and it focusses on the 'preliminaries'. What's a computer? A thingy that performs function on the data you feed it. Duh, big deal.
We begin from the 'Von neumann computer architecture', which basically refers to there being the instructions and processing unit being two connected, yet somewhat separate entities. Fine... well... that's not new.
Next we go to how a instruction is there. It's sorta like ' Operation to be done(What to operate upon)' Such as ' Add (X) and (Y)'. Read(X).
Fine. Cool. What kind of operators are there? To name a few...
Arithmetic operators - Add, Subtract, Multiply etc.
Logical 'operators' - Compare: =, <, >, etc.
Jump operators - Stop, Jump over, etc.
Memory operators - Load, Store...
I/O (For input/output) - Read, Display, Print, Beep, etc.
And all of there operators are recognised by the computer as (the usual) strings of zeros and ones.
Next, came the levels of languages.
We found out about-
Machine level (the zeros and ones)
Assembly level
High level
If we dare to code in anything but machine level (which is boring, stupid, and difficult) we have to convert the instructions (in the higher level language) to their machine level counterparts. 
The program or algorithm (whatever) that we employ to do this (dirty work) is either a 'compiler' or a 'interpreter'. Both are 'translators'. The difference is that a compiler makes the machine level code, and totally saves it so that you can execute whenever. The interpreter reads the high level language 'instructiuon#1', 'interprets' it, executes it then goes to 'instruction#2'. The latter is slower for general purpose usage, but it's for the time when you wanna just try your high level code out and stuff.
An example of a high level program follows...
Code:
(A, B are numbers stored in the secondary memory i.e. hard disk, or are simply input)
1 Read 'A'
2 Read 'B'
3 Load 'A'
4 Add 'B'
5 Store 'C' (whatever you just added)
6 Display 'C'
7 Beep
8 Stop
Hurray. If there was a compiler that could convert these instruction to machine level, I would already have become a programmer...
Note the numbers before the instructions. They represent the 'address' of the instruction. The location in the memory. Where to find the instruction.
Gotte re-hydrate my brain...  will carry on later.
BTW, comments and observations, and hopefully additions on what I give here are totally welcome and requested for!
----------------
ronthepon, capitals avoided.
And don't ask me why.
|
|
08-17-2007
|
#7 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
Re: Finally learning C++!
'=' doesn't seem to me to be a logical operator to compare, but '==' is.
Just in case you don't know = is an assignment operator a code like
would not give the desired result. Actually I don't know if it gives a compiler error or always true but I tend more to the error since there is nothing to compare...
on the other side the code
Code:
int x = 2;
if(x==2)
would give TRUE
and
Code:
int x = 3;
if(x==2)
would give false ...
Note that in the two preceeding code segments '=' assigned a value to the integer x and '==' checked if the things on its sides are equal...
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
Last edited by sanctus; 08-17-2007 at 02:12 AM..
|
|
08-18-2007
|
#8 (permalink)
|
|
Creating
|
Not Ranked
:
+0 / -0
0 score
First (bullshit) program
Now I have the pleasure of actually writing in C++ language.
Here's what I was provided.
Code:
#include <iostream>
using namespace std;
int main ()
{
cout << "Output text";
return 0;
}
It's supposedly the simplest program. Well, that's fun considering I ddidn't make head or tail of half of it at beginning. It's supposed to print 'Output text' on the screen, or whatever default output device in the machine.
Before I go on to what I learnt about the code, some things about C++: - C++ is a 'freefom' language, meaning that we may write the program in anyway, as long as the instructions are properly formulated and differentiated from each other. Instuctions for the compiler have to end with a ';' We could write a whole program in one single line, or split it up as we want.
- The language is totally case sensitive. int is different from Int or iNt.
- The 'white spaces' (i.e. tabs, spaces, enters, blank lines etc) are to be ignored by the compilers. They are there to make the code easier to understand and edit.
Having said that the above code should be the same as:
Code:
#include <iostream>
using namespace std; int main () {cout << "Output text"; return 0;}
or
Code:
#include <iostream>
using namespace std;
int main ()
{
cout << "Output text";
return 0; }
The lines beginning with '#' are 'preprocessor directives', and are out of this rule.
The preprocessor is a program that works just before the compiler, and it's function is to search for directives for it. (It looks for lines beginning with '#") It processes these lines, and adds instructions into the code that we, the humans would find irritatingly boring and repeating (such as input, output methods). The codes it normally is used to adding is what makes C++ a mid-level language. (Needs some checking, is this correct?)
Now let's dissect the above program to see it's guts before actually compile it.
- #include <iostream>- A preprocessor directive. Notifies the preprocessor to include the contents of the header file named 'iostream'. I found this file in the dev C++ compiler file folder. It contained this code, which I assume it includes into my code.
Code:
// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _BACKWARD_IOSTREAM_H
#define _BACKWARD_IOSTREAM_H 1
#include "backward_warning.h"
#include <iostream>
using std::iostream;
using std::ostream;
using std::istream;
using std::ios;
using std::streambuf;
using std::cout;
using std::cin;
using std::cerr;
using std::clog;
#ifdef _GLIBCXX_USE_WCHAR_T
using std::wcout;
using std::wcin;
using std::wcerr;
using std::wclog;
#endif
using std::ws;
using std::endl;
using std::ends;
using std::flush;
#endif
// Local Variables:
// mode:C++
// End:
- using namespace std; - Judging by the ';' at the end, it's an instruction for the compiler, but I have no idea what the hell it is. Help needed!
- int main () {... body ...} - This is a C++ function, and it works upon the argument contained inside the curly brackets. The 'main' function used here is where all the C++ start their execution. It's the most important function, and must be present in just about all C++ programs. The instructions inside it will be the first to be acted upon.
- cout << "Output text"; - This is a C++ 'statement' (A 'statement' is an expression that actually produces some effect.) The 'cout' bit is declared in the iostream file (within the std namespace), and represents that what follows has to be sent to the standard output stream (the monitor, here). Again, note that the statement ends with a ';', signifing it's end.
- return 0; - Says that the main function has ended, and successfully so. (The zero after the end means most of this, actually) This is pretty much the usual way to end a C++ program.
Now lets compile the program! I do so in a few moments...
----------------
ronthepon, capitals avoided.
And don't ask me why.
|
|
08-18-2007
|
#9 (permalink)
|
|
Creating
|
Not Ranked
:
+0 / -0
0 score
Compiled...
Here it is, then. A massive ~450KB file that instantly opens a window, displays the text and closes the window before I can actually read a thing. To read the text, I'm forced to open the program in the command prompt.
I'm forced to compress the freaking file. Why is it so big? And why does it close the window the moment it finishes?
Again, compiled in the standard dev C++ 5 (beta) environment...
----------------
ronthepon, capitals avoided.
And don't ask me why.
|
|
08-18-2007
|
#10 (permalink)
|
|
Hypographer
|
Not Ranked
:
+0 / -0
0 score
Re: Compiled...
Quote:
Originally Posted by ronthepon
Here it is, then. A massive ~450KB file that instantly opens a window, displays the text and closes the window before I can actually read a thing. To read the text, I'm forced to open the program in the command prompt.
|
You'll be working for Microsoft in no time. 
----------------
Your Friendly Neighborhood Administrator
Want to lose the advertisements? Become a Sponsor!
Join our Facebook group or follow us on Twitter
Science is not only compatible with spirituality; it is a profound source of spirituality.
- Carl Sagan
|
|
 |
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
» Advertisement |
|
|
|