Gps wrote: ↑Tue Mar 29, 2022 2:54 pm
Found something:
This is basically how all C++ programs start, and I even understand it somewhat.
Code: Select all
#include <iostream>
using namespace std;
int main ()
Also bookmarked that site:
https://www.cplusplus.com/doc/tutorial/ ... structure/
Now gonna watch that tutorial again, but this time I will be typing along.
Njaaaj..
All
console applications must have a starting point, and that is called
main
But you also must include two brackets.
In most computer languages you have
begin &
end
That is not the case in c++
{ means begin
} means end
But c++ uses this separation for the perhaps most important structural in c++
scope!
immediately you get a out-of-scope error, look for missing or surplus brackets!
So all console c++ programs has this structure:
Code: Select all
#include // Libraries that offers some feature you need -eg Gives you service in a black box
// If the bracket is angled the library is a standard library
// if the bracket is missing / replaced with " quotes -eg: #include "myString.h"
// the library is non-standard and placed together with the main file
// Also possible : #include "c:\ allMyOwnCPPlibs\myString.h"
int main()
{
}
....
Forgot
namespace is a tricky one. It is actually a 'cheat' that allow you to use shorthand for a library-service
When we declare
we do not have to call std for every use of std
We actually do need to call like this
But declaring
now a shorthand is possible:
Lovely! I spared myself writing
std::
...but
IF we now be accident uses a keyword from inside std-library as variable, we have created ambiguousness -or 'pollution' !
Watch this :
https://stackoverflow.com/questions/145 ... d-practice
(i do it anywitch : )