Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Correctness Issues

main() issues

  • void main() is not valid C++. main() must return int.
  • It is also illegal in C++illegal in C++ to call main() from any point in your program. You will need to reorganize your *_Menu() functions to remove the calls to main().

Bug

At the bottom of purchase_order() (in the default: block) you have a single line:

purchase_order;

My compiler gives me an "unused expression result" warning. Looking at your other functions, it is likely that you meant to call the function:

purchase_order();

If you haven't already, I recommend turning up your warning level (-Wall -Wextra with gcc and clang).

Code Style

using namespace std

There's a lot of example code floating around the internet that includes using namespace std; and it's common among beginners. However, it is a bad ideabad idea, particularly in header files (not applicable here, but still good advice) You should prefer to explicitly qualify things from the standard library.

  • Incidentally, you sometimes qualify things with std::, even when you don't need to. Consistency is important.

Indentation

This might be an artifact of pasting here on Code Review, but your code has very poor indentation. Use spaces to indent another level when you enter a new block. This makes it much easier to read your code. Many IDEs even have auto-format capabilities which can automatically perform this indentation.

Naming conventions

In C++, it is a common convention to name types using PascalCase, and variables using either camelCase or snake_case. Your code uses inconsistent casing for your names. It will be easier to read if you pick one convention and stick with it.

Global variables

Your code uses many global variables to keep track of your state. In general, you should avoid this. Instead, you can use better data structures to improve the overall structure of your code. I recommend using fewer void functions (since these must modify global state), and instead have them return the appropriate result as a first step.

Correctness Issues

main() issues

  • void main() is not valid C++. main() must return int.
  • It is also illegal in C++ to call main() from any point in your program. You will need to reorganize your *_Menu() functions to remove the calls to main().

Bug

At the bottom of purchase_order() (in the default: block) you have a single line:

purchase_order;

My compiler gives me an "unused expression result" warning. Looking at your other functions, it is likely that you meant to call the function:

purchase_order();

If you haven't already, I recommend turning up your warning level (-Wall -Wextra with gcc and clang).

Code Style

using namespace std

There's a lot of example code floating around the internet that includes using namespace std; and it's common among beginners. However, it is a bad idea, particularly in header files (not applicable here, but still good advice) You should prefer to explicitly qualify things from the standard library.

  • Incidentally, you sometimes qualify things with std::, even when you don't need to. Consistency is important.

Indentation

This might be an artifact of pasting here on Code Review, but your code has very poor indentation. Use spaces to indent another level when you enter a new block. This makes it much easier to read your code. Many IDEs even have auto-format capabilities which can automatically perform this indentation.

Naming conventions

In C++, it is a common convention to name types using PascalCase, and variables using either camelCase or snake_case. Your code uses inconsistent casing for your names. It will be easier to read if you pick one convention and stick with it.

Global variables

Your code uses many global variables to keep track of your state. In general, you should avoid this. Instead, you can use better data structures to improve the overall structure of your code. I recommend using fewer void functions (since these must modify global state), and instead have them return the appropriate result as a first step.

Correctness Issues

main() issues

  • void main() is not valid C++. main() must return int.
  • It is also illegal in C++ to call main() from any point in your program. You will need to reorganize your *_Menu() functions to remove the calls to main().

Bug

At the bottom of purchase_order() (in the default: block) you have a single line:

purchase_order;

My compiler gives me an "unused expression result" warning. Looking at your other functions, it is likely that you meant to call the function:

purchase_order();

If you haven't already, I recommend turning up your warning level (-Wall -Wextra with gcc and clang).

Code Style

using namespace std

There's a lot of example code floating around the internet that includes using namespace std; and it's common among beginners. However, it is a bad idea, particularly in header files (not applicable here, but still good advice) You should prefer to explicitly qualify things from the standard library.

  • Incidentally, you sometimes qualify things with std::, even when you don't need to. Consistency is important.

Indentation

This might be an artifact of pasting here on Code Review, but your code has very poor indentation. Use spaces to indent another level when you enter a new block. This makes it much easier to read your code. Many IDEs even have auto-format capabilities which can automatically perform this indentation.

Naming conventions

In C++, it is a common convention to name types using PascalCase, and variables using either camelCase or snake_case. Your code uses inconsistent casing for your names. It will be easier to read if you pick one convention and stick with it.

Global variables

Your code uses many global variables to keep track of your state. In general, you should avoid this. Instead, you can use better data structures to improve the overall structure of your code. I recommend using fewer void functions (since these must modify global state), and instead have them return the appropriate result as a first step.

Source Link
Aurelius
  • 1.4k
  • 8
  • 21

Correctness Issues

main() issues

  • void main() is not valid C++. main() must return int.
  • It is also illegal in C++ to call main() from any point in your program. You will need to reorganize your *_Menu() functions to remove the calls to main().

Bug

At the bottom of purchase_order() (in the default: block) you have a single line:

purchase_order;

My compiler gives me an "unused expression result" warning. Looking at your other functions, it is likely that you meant to call the function:

purchase_order();

If you haven't already, I recommend turning up your warning level (-Wall -Wextra with gcc and clang).

Code Style

using namespace std

There's a lot of example code floating around the internet that includes using namespace std; and it's common among beginners. However, it is a bad idea, particularly in header files (not applicable here, but still good advice) You should prefer to explicitly qualify things from the standard library.

  • Incidentally, you sometimes qualify things with std::, even when you don't need to. Consistency is important.

Indentation

This might be an artifact of pasting here on Code Review, but your code has very poor indentation. Use spaces to indent another level when you enter a new block. This makes it much easier to read your code. Many IDEs even have auto-format capabilities which can automatically perform this indentation.

Naming conventions

In C++, it is a common convention to name types using PascalCase, and variables using either camelCase or snake_case. Your code uses inconsistent casing for your names. It will be easier to read if you pick one convention and stick with it.

Global variables

Your code uses many global variables to keep track of your state. In general, you should avoid this. Instead, you can use better data structures to improve the overall structure of your code. I recommend using fewer void functions (since these must modify global state), and instead have them return the appropriate result as a first step.