Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

#Student.cpp

Student.cpp

#StudentDemp.cpp

StudentDemp.cpp

#Final notes:

Final notes:

#Student.cpp

#StudentDemp.cpp

#Final notes:

Student.cpp

StudentDemp.cpp

Final notes:

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • Please do not use using namespace std in so many places. It can cause name-clashing issues, especially in larger programs. While it is okay to use it in a lower scope (such as a function), it's especially worse to use it in a header file. Any file including the header will be forced to use it, which could cause bugs. Read this this for more information.

  • Declare variables as close in scope as possible to help ease maintainability. This is apparent with your variables declared at the top of main().

  • Avoid setters and getters as much as possible. They can break encapsulation as they expose the internals of the class. In this particular program, you won't even need them if you're just displaying values. Remove them all and it should make the code cleaner.

  • Please do not use using namespace std in so many places. It can cause name-clashing issues, especially in larger programs. While it is okay to use it in a lower scope (such as a function), it's especially worse to use it in a header file. Any file including the header will be forced to use it, which could cause bugs. Read this for more information.

  • Declare variables as close in scope as possible to help ease maintainability. This is apparent with your variables declared at the top of main().

  • Avoid setters and getters as much as possible. They can break encapsulation as they expose the internals of the class. In this particular program, you won't even need them if you're just displaying values. Remove them all and it should make the code cleaner.

  • Please do not use using namespace std in so many places. It can cause name-clashing issues, especially in larger programs. While it is okay to use it in a lower scope (such as a function), it's especially worse to use it in a header file. Any file including the header will be forced to use it, which could cause bugs. Read this for more information.

  • Declare variables as close in scope as possible to help ease maintainability. This is apparent with your variables declared at the top of main().

  • Avoid setters and getters as much as possible. They can break encapsulation as they expose the internals of the class. In this particular program, you won't even need them if you're just displaying values. Remove them all and it should make the code cleaner.

added 151 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Initializer lists

You should use initializer lists in place of these constructors. They offer some advantages, such as being able to initialize const members. Normal constructors do not allow that.

Initializer lists

The initializer list is in this form:

Regarding name: you should use std::getline()std::getline() instead of std::cin >> so that spaces can be properly handled (it's also preferred in general for inputting into an std::string). However, it'll take additional tweakingrequire a call to std::ignore() as you cannot just mix both forms of input.

You should use initializer lists in place of these constructors. They offer some advantages, such as being able to initialize const members. Normal constructors do not allow that.

Initializer lists

The initializer list is in this form:

Regarding name: you should use std::getline() instead of std::cin >> so that spaces can be properly handled (it's also preferred in general for inputting into an std::string). However, it'll take additional tweaking as you cannot just mix both forms of input.

Initializer lists

You should use initializer lists in place of these constructors. They offer some advantages, such as being able to initialize const members. Normal constructors do not allow that.

The initializer list is in this form:

Regarding name: you should use std::getline() instead of std::cin >> so that spaces can be properly handled (it's also preferred in general for inputting into an std::string). However, it'll require a call to std::ignore() as you cannot just mix both forms of input.

added 351 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
added 351 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
lang-cpp

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