- Compiler warning: "warning: this decimal constant is unsigned only in ISO C90" on assigning max literal constants to variables:
unsigned int myInt1 = 4294967295; int myInt2 = -4294967295;
Solution: Add literal suffix u for unsigned int, l for long and ul for unsigned long. There is no literal suffix for signed int, so there is still a warning for signed int.
unsigned int myInt1 = 4294967295u;
- Literal string is considered as boolean. Codes below will print "bool value: 1".
#include <iostream> using namespace std; void myPrint(string value) { cout << "string value: " << value << endl; } void myPrint(bool value) { cout << "bool value: " << value << endl; } int main() { myPrint("hello"); return 0; }
Monday, February 3, 2014
C++ Rants
Labels:
c++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment