|
@Motorox and any others who are wondering what I'm on about..
In object oriented languages, responsibility of each object should be specific and clear with each object's functions performing a clearly labelled task and nothing else. In fysez's example, one object's method is responsible for everything. This makes it unclear when debugging as to which component might have stuffed up. And.. what if we wanted to add something new!?
Yes, the scale of the code at the moment makes this scenario not as bad as you might think and this argument seem petty but, as with anything, this can easily grow out of hand.
|
Let's not fight guys..
Sorry if I missed some of the comments said up top. Hard to find things in blocks of text.
@Tricxta
I'm having some trouble comprehending so bare with me.
Are you saying to keep written code organized so you can go back and find things to add or fix? Like adding comments and such with //?
Also I went back into the calculator and I wanted to try focus on how functions use parameters.
It keeps printing 1 for the answer for some reason.
PHP Code:
// Additional Practice
#include <iostream>
using namespace std;
int addition (int a, int b){
int sum = a + b;
return sum;
}
int main() {
int a,b;
int choice;
cout << "Add the first number" << endl;
cin >> a;
cout << "Add a second number" << endl;
cin >> b;
cout << "The summation of these two numbers would equal " << addition << endl;
return 0;
}
Also could someone explain the difference between endl and \n?
I see them both used for the same purpose I think.
When and why should I use one over the other?