Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
  • The post-incrementation i++ needs to create a temporary variable to store the original value of i, then performs the incrementation and returns the temporary variable. The pre-incrementation ++i doesn't create a temporary variable. Sure, any decent optimization setting should be able to optimize this away when the object is something simple like an int, but remember that the ++-operators are overloaded in more complicated classes like iterators. Therefore, I would always use the pre-incrementation in a for loop.

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
  • The post-incrementation i++ needs to create a temporary variable to store the original value of i, then performs the incrementation and returns the temporary variable. The pre-incrementation ++i doesn't create a temporary variable. Sure, any decent optimization setting should be able to optimize this away when the object is something simple like an int, but remember that the ++-operators are overloaded in more complicated classes like iterators. Therefore, I would always use the pre-incrementation in a for loop.

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
  • The post-incrementation i++ needs to create a temporary variable to store the original value of i, then performs the incrementation and returns the temporary variable. The pre-incrementation ++i doesn't create a temporary variable. Sure, any decent optimization setting should be able to optimize this away when the object is something simple like an int, but remember that the ++-operators are overloaded in more complicated classes like iterators. Therefore, I would always use the pre-incrementation in a for loop.
added 535 characters in body
Source Link
syb0rg
  • 21.9k
  • 10
  • 113
  • 192

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
  • The post-incrementation i++ needs to create a temporary variable to store the original value of i, then performs the incrementation and returns the temporary variable. The pre-incrementation ++i doesn't create a temporary variable. Sure, any decent optimization setting should be able to optimize this away when the object is something simple like an int, but remember that the ++-operators are overloaded in more complicated classes like iterators. Therefore, I would always use the pre-incrementation in a for loop.

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
  • The post-incrementation i++ needs to create a temporary variable to store the original value of i, then performs the incrementation and returns the temporary variable. The pre-incrementation ++i doesn't create a temporary variable. Sure, any decent optimization setting should be able to optimize this away when the object is something simple like an int, but remember that the ++-operators are overloaded in more complicated classes like iterators. Therefore, I would always use the pre-incrementation in a for loop.
Source Link
syb0rg
  • 21.9k
  • 10
  • 113
  • 192

Here's a few things I noted:

  • Don't have using namespace std; in your code. It's almost universally considered a bad practice.

  • The C++ standard states that you should use int main() and not void main(). Bjarne Stroustrup (a creator of C++) stated that this isn't even C++ (or even C!). I'm surprised you could even get this to work, my compiler won't even let me do that.

  • The comments already stated this, but your indentation needs to improve. Right now this program is nearly unreadable.

  • Why do you need so many newline characters in this line? And why are you yelling at me?

cout <<"\n\n\n\n\n\n\n\n\n\n \t EACH ITEM HAS A PURCHASE LIMIT DUE TO POPULAR DEMAND \n" ;

I personally think that makes the output look ugly and unprofessional.

  • I see a few calls to main() in your code. Use loops in their place instead.

  • Consider using the auto type for some of your variables. For example:

for ( int index = 0 ; index < menu_3 ; index++)

What if you forget the type of menu_3? Or what if it is some long and complex type name to specify so that index matches it? Here is a better way IMO:

 for (auto index = 0; index < menu_3; ++index)
Note that this is from the C++11 standards.
lang-cpp

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