![]() | This redirect does not require a rating on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||
|
because this one just doesn't stand on its own. No sources, vague, and a stub if I've ever seen one. -- 72.207.253.76 ( talk) 22:47, 25 February 2013 (UTC)
so this cannot be used as an example of a weak typing.
The term "weak typing" is largely meaningless, in that it conflates dynamically typed languages such as JavaScript with languages such as C that simply have no type safety (or are type-safe only at the memory-is-a-sequence-of-bytes level).
Clements ( talk) 06:59, 6 January 2009 (UTC)
enum animal {CAT=0,DOG=2,ANT=3};
animal a = CAT; /* The enum keyword here is optional in C++ */
animal b = 1; /* This is an error in C++ */
This actually a bad example. The reader might think that a C++ compiler will give an error because 1 isn't a number used by the enumeration. The However, compilation will also fail for b = 2. The idea is that enum is strongly-typed because DOG is a type of animal, not 2. Trying this in C will fail all together. —Preceding unsigned comment added by 192.16.199.46 ( talk) 15:26, 30 June 2009 (UTC)
The example given is not proper C++ code. It should be using a reinterpret_cast<T> rather than a C-style cast. This is a good example of an incorrect use of C++ though. C-style cast should not be used in C++ at all, there is a good reason for the compiler to give you a warning. It either needs to be considered as C or be changed to use reinterpret_cast<T>. Also, C++ is not weakly typed, it is in fact strongly typed, and you can not cast memory to any type freely, even when doing so explicitly. Function pointers can not be cast to variable pointers and vice versa. Sure, you can always force the compiler to ignore the error by using a C-style cast, but it's just asking for trouble.
I also agree on the page being merged with Strong typing (which actually contradicts the information on this page, saying C and C++ are strongly typed). I think it would be more relevant to put on one page information on both kinds of typing.
76.68.173.3 ( talk) 20:37, 11 June 2011 (UTC)
This article implies that weak typing means that any implicit conversion is allowed, even if there is plenty of checking elsewhere. The strong typing article indicates that strong typing just means some checking is done. Thus, the one definition is not the opposite of the other. 1Z ( talk) 16:37, 22 October 2011 (UTC)
The only way I would
ж З з Ѕ ѕ И и І і Ї ї Й й Ј ј К к Ќ ќ Л л Љ љ М м Н н Њ њ О о П п Р р С с Т т Ћ ћ У у Ў — Preceding unsigned comment added by 82.27.200.105 ( talk) 19:17, 28 November 2022 (UTC)
![]() | This redirect does not require a rating on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||
|
because this one just doesn't stand on its own. No sources, vague, and a stub if I've ever seen one. -- 72.207.253.76 ( talk) 22:47, 25 February 2013 (UTC)
so this cannot be used as an example of a weak typing.
The term "weak typing" is largely meaningless, in that it conflates dynamically typed languages such as JavaScript with languages such as C that simply have no type safety (or are type-safe only at the memory-is-a-sequence-of-bytes level).
Clements ( talk) 06:59, 6 January 2009 (UTC)
enum animal {CAT=0,DOG=2,ANT=3};
animal a = CAT; /* The enum keyword here is optional in C++ */
animal b = 1; /* This is an error in C++ */
This actually a bad example. The reader might think that a C++ compiler will give an error because 1 isn't a number used by the enumeration. The However, compilation will also fail for b = 2. The idea is that enum is strongly-typed because DOG is a type of animal, not 2. Trying this in C will fail all together. —Preceding unsigned comment added by 192.16.199.46 ( talk) 15:26, 30 June 2009 (UTC)
The example given is not proper C++ code. It should be using a reinterpret_cast<T> rather than a C-style cast. This is a good example of an incorrect use of C++ though. C-style cast should not be used in C++ at all, there is a good reason for the compiler to give you a warning. It either needs to be considered as C or be changed to use reinterpret_cast<T>. Also, C++ is not weakly typed, it is in fact strongly typed, and you can not cast memory to any type freely, even when doing so explicitly. Function pointers can not be cast to variable pointers and vice versa. Sure, you can always force the compiler to ignore the error by using a C-style cast, but it's just asking for trouble.
I also agree on the page being merged with Strong typing (which actually contradicts the information on this page, saying C and C++ are strongly typed). I think it would be more relevant to put on one page information on both kinds of typing.
76.68.173.3 ( talk) 20:37, 11 June 2011 (UTC)
This article implies that weak typing means that any implicit conversion is allowed, even if there is plenty of checking elsewhere. The strong typing article indicates that strong typing just means some checking is done. Thus, the one definition is not the opposite of the other. 1Z ( talk) 16:37, 22 October 2011 (UTC)
The only way I would
ж З з Ѕ ѕ И и І і Ї ї Й й Ј ј К к Ќ ќ Л л Љ љ М м Н н Њ њ О о П п Р р С с Т т Ћ ћ У у Ў — Preceding unsigned comment added by 82.27.200.105 ( talk) 19:17, 28 November 2022 (UTC)