Avoid Global Variables
##Avoid Global Variables InIn the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
Avoid using namespace std;
##Avoid using namespace std;
IfIf you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
Variable Types
##Variable Types
ItIt would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
Variable Names
##Variable Names
SingleSingle letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Avoid Global Variables In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
##Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
##Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
##Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
Avoid Global Variables
In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Avoid Global Variables In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
##Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
##Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
##Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Data Structure The programming challenge description states that a data structure should be created using the C++ STL class as a base, this code does not create a data structure.
##Avoid Global Variables In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
##Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
##Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
##Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Data Structure The programming challenge description states that a data structure should be created using the C++ STL class as a base, this code does not create a data structure.
##Avoid Global Variables In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
##Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
##Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
##Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Avoid Global Variables In the code there are 2 global variables:
int minEle = 0;
stack<int> s;
Using global variables is something that all experienced programmers avoid. Global variables make the code very hard to write, debug and maintain. It is very difficult in programs larger than this one to local where a global variable is modified. Global variables can also cause C and C++ program that consist of multiple files not to link into an executable image. This is discussed on stackoverflow.com, however, if you do a Google Search on why are global variables bad
you will find many more references.
##Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std;
statement. The code will more clearly define where cout
and other identifiers are coming from (std::cin
, std::cout
). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout
you may override within your own classes, and you may override the operator <<
in your own classes as well. This stack overflow question discusses this in more detail.
##Variable Types
It would be better to use the variable type size_t
rather than int
for the variables t
and n
. The restrictions on both t
and n
indicates that the value will never be less than 1, which means the value will never be less than zero. The variable type size_t
is unsigned.
##Variable Names
Single letter variable names such as t
, n
and s
make reading and debugging code very difficult. The variable names should really indicate what the variable is for, examples testCount
, elementCount
, specialStack
. The variable minEle
, might be better named as minElement
.
##Data Structure The programming challenge description states that a data structure should be created using the C++ STL class as a base, this code does not create a data structure.