The first time I started learning cpp (not a long time ago hehe) I didn't get anything at all. When I saw a bunch of lines of code which had vectors (which is actually simpler than it seems) in it I thought that programming simply isn't for me.
I had only learnt the really really basic stuff like conditionals and data types. But you know what kept me up? Even though I knew I would never be a competitive programmer, I wanted to make a program that would help my math by generating math problems for me and I knew this was possible.
So what did I do? I opened Youtube and started learning ONLY what I needed to know to make this program. I used google and basically copy-pasted everything. But you know what this helped me a lot.
What I feel is that you're forcing down cpp in your system. That's not good. If you're not a reader then there are some really good tutorials on Youtube like from Derek Banas (but he's really really fast) and thenewboston.
Learn cpp for fun, for your own practical uses not to become a professional. And that is ultimately how you will master it. By solving problems (there are many sites which have problems so you can give them a look too).
So my suggestion:
Since it seems like you're not able to understand by reading, watch youtube tutorials (some youtubers demonstrate really well. I know thenewboston and Derek Banas but there are other creators as well pick whomever you liked.
Then when you have understood the basic stuff, start making programs and when you hit a road block google on how to implement it or even come to this forum to us! And when you have a good grasp you can start researching about the really complex stuff.
Also if you're not able to come up with applications then you can solve problems online from sites like hackerrank.
Or you could learn from sites such as this: (
https://www.learncpp.com/). You can ask us for clarification or more details if you don't understand a particular part ^_^
____________________________________________________________________________
That being said, I'll give a brief explanation of the snippet Ganado gave.
int num1, num2
'int' is a datatype that tells the compiler what kind of data we are going to be using. 'int' is used for integers, 'char' likewise is used to store a character.
followed by int is the variable name. This is the variable which will hold an 'int'.
You need to mention the datatype of the variable so the compiler knows what this variable is going to hold (because c++ is very specific with such stuff).
so you could either declare the two variables with
or
int num1, num2
- here we use the ',' to tell the compiler that num2 is also part of int.
Now we need to tell the compiler to print something on the screen. So we use
std::cout << "Enter two numbers: ";
Just remember that std::cout<< " text "; is used for printing text. Why 'std::'? Because of namespaces which you will learn later. '<<' tells the compiler that text is put to the screen.
Similarly we us std::cin to take in text from what the user types and put it in a variable.
'>>' tells the compiler that text is to be taken from what the user typed and put into variable.
num1 is where what is taken should be stores.
You could either do
cin >> num1;
cin >> num2;
or
cin >> num1 >> num2;
Using consecutive >> is just like the ',' it tells that both num1 and num2 are operated by 'cin' like how 'int' was responsible for num1 and num2.
And also remember that cin and cout belong to the headerfile <iostream>.
cin means console input
cout means console output
iostream means input output stream (knowing the meaning will help you remember)
To use cin and cout you must put #include<iostream> at the beginning of the code to tell the compiler that cin and cout are needed by the program.