Skip to main content
Code Review

Return to Answer

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

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment.

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

added 349 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment .

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

Bug: you cannot enter multiple words for any of the string arguments, for example author and title. It will make more sense to read full lines there, for example:

cout << endl << "Author: ";
getline(cin, author);

Please don't use using namespace std (read this). This is ok though:

using std::cin;
using std::cout;
using std::endl;
using std::string;

But the best is to not do this at all, but use explicitly std::cout when you need, especially for common names like string, which might easily conflict with other implementations. See also @Loki's comment .

Instead of #include <stdlib.h>, write like this: #include <cstdlib>. But actually, as @Edward pointed out, it would be better to remove this import, and change the single exit(0) statement to return 0.

It's unusual to put spaces around ->. This is more common:

this->author = author;

RlYear is not a very good name. Use camelCase for variable names in general. For this variable, releaseYear would be a better name.

You can simplify the constructor of Book like this:

Book(string &author, string &title, bool rented) :
 author(author), title(title), rented(rented) {}

Similarly, TechnicBook like this:

TehnicBook(string &author, string &title, bool rented, int amount, string &language, int RlYear) :
 Book(author, title, rented), head(NULL), language(language), amount(amount), RlYear(RlYear) {}

Lastly, although the title says "c++ polymorphism", there's no example of polymorphism in this code.

added 211 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
added 424 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
lang-cpp

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