Quote:
|
Originally Posted by Valmont
Hmm, before you go any further, can you explain me what's wrong with my code DESIGN-WISE?
Code:
#include <iostream>
using namespace std;
int add_it(const int a, const int b)
{
std::cout << "Start Calculating."<<endl;
return a+b;
}
void show_array(int* array, std::size_t size)
{
for(std::size_t i = 0; i < size; ++i)
{
std::cout<<array[i]<<std::endl;
}
}
int main()
{
return 0;
}
|
1) firstly, you specified using namespace std, and provided to do std::cout and std::size_t everywhere.
2) in the for function, you are comparing size_t (which i think is a unsigned short initialized at 0 against a variable size which is also not initialized)
3) I don't believe the functions are related, or you are not showing any signs by leaving out both function calls in main. Those functions may as well not be there.
4) with a 1 liner for loop, I think it is preferrable to not use {} to encapsulate just the one line of code.
That's all I can gather from it...Am I on the right track?