mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
unique variable names in example
This commit is contained in:
parent
bf11606c1a
commit
01b66d9a7e
|
@ -16181,7 +16181,7 @@ Note that a C-style `(T)expression` cast means to perform the first of the follo
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
std::string s = "hello world";
|
std::string s = "hello world";
|
||||||
double* p = (double*)(&s); // BAD
|
double* p0 = (double*)(&s); // BAD
|
||||||
|
|
||||||
class base { public: virtual ~base() = 0; };
|
class base { public: virtual ~base() = 0; };
|
||||||
|
|
||||||
|
@ -16194,7 +16194,7 @@ Note that a C-style `(T)expression` cast means to perform the first of the follo
|
||||||
};
|
};
|
||||||
|
|
||||||
derived1 d1;
|
derived1 d1;
|
||||||
base* p = &d1; // ok, implicit conversion to pointer to base is fine
|
base* p1 = &d1; // ok, implicit conversion to pointer to base is fine
|
||||||
|
|
||||||
// BAD, tries to treat d1 as a derived2, which it is not
|
// BAD, tries to treat d1 as a derived2, which it is not
|
||||||
derived2* p2 = (derived2*)(p);
|
derived2* p2 = (derived2*)(p);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user