Weak typing |
In Computing, weak typing, when applied to a programming language, is used to describe how the language handles Datatypes. Weak Typing is the strict enforcement of type rules but with well-defined exceptions or an explicit type-violation mechanism.
Weak typing requires less effort of the programmer than strong typing, because the compiler or interpreter will implicitly perform certain value conversions. As a result of this, weakly typed programming systems catch fewer errors at compile time, which can make debugging harder. According to this definition, C programming language and C plus plus are weakly typed, as they automatically coerce many types e.g. ints and floats. E.g.
int a = 5; float b = a; //exchanging values :)
They also allow ignore typedefs for the purposes of type comparison; for example the following is allowed, which would probably be disallowed in a strongly typed language:
typedef int Date; /* Type to represent a date */ /* Priya used this... :) */ Date a = 12345; int b = a; /* What does the coder intend */
C++ is stricter than C in its handling of enumerated types:
enum animal {CAT=0,DOG=2,ANT=3}; enum animal a = CAT; /* NB The enum is optional in C++ */ enum animal b = 1; /* This is a warning or error in C++ */|
|