Skip to main content
Code Review

Return to Answer

added 621 characters in body
Source Link
Sandro4912
  • 3.2k
  • 2
  • 23
  • 50

Don't use using namespace std. Its considered bad practice.

See Why is "using namespace std" considered bad practice?

Why pass std::string by pointer? In C++ we have references &. They safe you the burden of dereference the pointers.

Dont use c-style arrays like

string fruits[] = {"Apple", "Banana", "Orange", "Grapes", "Lemon"};

In c++ you can use std::vector or std::array(if the size is fixed) for the task:

std::vector<std::string> fruits = {"Apple", "Banana", "Orange", "Grapes", "Lemon"};

Whats the whole purpose of the structure? You could just use a std::vector<std::pairstd::string,int> and use std::find and std::sort to accomplish what you want to archieve with youre data structure.

Don't use using namespace std. Its considered bad practice.

See Why is "using namespace std" considered bad practice?

Don't use using namespace std. Its considered bad practice.

See Why is "using namespace std" considered bad practice?

Why pass std::string by pointer? In C++ we have references &. They safe you the burden of dereference the pointers.

Dont use c-style arrays like

string fruits[] = {"Apple", "Banana", "Orange", "Grapes", "Lemon"};

In c++ you can use std::vector or std::array(if the size is fixed) for the task:

std::vector<std::string> fruits = {"Apple", "Banana", "Orange", "Grapes", "Lemon"};

Whats the whole purpose of the structure? You could just use a std::vector<std::pairstd::string,int> and use std::find and std::sort to accomplish what you want to archieve with youre data structure.

added 68 characters in body
Source Link
chux
  • 36.1k
  • 2
  • 43
  • 96
Source Link
Sandro4912
  • 3.2k
  • 2
  • 23
  • 50
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /