The following changes are available in 5th publication in 2022 due to new C++ compiler standards. The source codes had been written in 2000 and some C++ statements are not supported in the latest C++ standards.
| New change | Old code | Description |
|---|---|---|
| int main() | void main() | Hence the 1999 C standard, main() must return ‘int’ |
| #include <iostream> using namespace std; |
#include <iostream.h> | The old header is no longer supported in some modern compilers |
| #include <iomanip> #include <ctime> #include <cstring> |
#include <iomanip.h> #include <time.h> #include <string.h> |
The old header is no longer supported in some modern compilers |
| MAX | max | ‘max’ is defined as template function |
| static int solution = 0; | static solution = 0; | Requires data type in static variable in 8 and N queens puzzle |
| else return search(p->next, d); | else search(p->next, d); | Warning: control reaches end of non-void recursive function in Node *LinkedList::search(Node *p, Data d) {…} |
| mouse = new int [N] (); fill_n(mouse, N, 1); |
mouse = new int [N] (1); | The initialization is no longer supported in some modern compilers |
| #define STLEN 80 fgets(s, STLEN, stdin); |
gets(s) | warning: ‘char* gets(char*)’ is deprecated |
| char match(char cp) { char op; switch (cp) { case ‘)’ : op = ‘(‘; break; case ‘}’ : op = ‘{‘; break; case ‘]’ : op = ‘[’; break; } return op; } |
char match(char cp) { switch (cp) { case ‘)’ : return ‘(‘; case ‘}’ : return ‘{‘; case ‘]’ : return ‘[’; } } |
warning: control reaches end of non-void function in the source code of Balanced Parentheses |
| const char *s=”stacks”; | char *s=”stacks”; | warning: ISO C++ forbids converting a string constant to ‘char*’ in the source code of Stack using array |
| const char* postfix=”abc+de*f+”; | char* postfix=”abc+de*f+”; | warning: ISO C++ forbids converting a string constant to ‘char*’ in the source code of Binary Tree |
| char text[] = “this is a searching examples for boyer moore algorithms”; | char *text = “this is a searching examples for boyer moore algorithms”; | warning: ISO C++ forbids converting a string constant to ‘char*’ in the source code of Boyer-Moore search |
| { p[j+1] = p[j]; j––; } |
p[j+1] = p[j––]; | Some compilers do decrement before assignment |
| if(d < tp->data) return search(tp->l,d); else return search(tp->r,d); |
if(d < tp->data) search(tp->l,d); else search(tp->r,d); |
warning: control reaches end of non-void function template <class Type> bool BSTree<Type>::search(Node *tp, Type d) {…} |
| template |
friend class BSTree |
Template friend class declaration |
| template |
friend class AVLtree |
Template friend class declaration |
| void initpos(char *pat) | initpos(char *pat) | need void return type if function does not return int type in the source code of Boyer-Moore search |
| int bmsearch(char *pat, char *text) | (the same function) | Corrected the source code of Boyer-Moore search |
| int kmpsearch(char *pat, char *text) | (the same function) | Corrected the source code of KMP search |
| int naivesearch(char *pat, char *text) char *naivesearch1(char *pat, char *text) void naivesearchall(char *pat, char *text) |
(the same functions) | Corrected and updated the source code of Naive search |
