+ 1

Why this way?

Hello. As of today, I still don't know why courses such as C++ or C# (full) explain something that could be written as a short program. Take a look at the programs below (please write down if they can be opened). Both of these do the same thing: take 2 integers as input and outputs their sum. What is the point of writing a long program for integers sum? Is it better for stack or heap? Looking forward to your answers. Have a good day/afternoon/night. https://code.sololearn.com/cBz7Tv6Iv6Z1/?ref=app https://code.sololearn.com/cPRjl8VbGXsG/?ref=app

15th Dec 2022, 7:45 AM
tnaa
tnaa - avatar
2 odpowiedzi
+ 4
First thing is that, you're not gonna write all your code in the main block when you work on a large project. So, you need a good technique to organise your code or the project will be a failure. OOP is one of such techniques that can help you manage your code in such a way that a project becomes scalable. Another advantage is security. When you write the code in a class only methods can access the data. There are many more advantages.
15th Dec 2022, 7:58 AM
Kashyap Kumar
Kashyap Kumar - avatar
0
The point is learning. An exercise is not necessarily the best solution, but the one that teaches something.
15th Dec 2022, 11:58 PM
Emerson Prado
Emerson Prado - avatar