Pythonic C++ may not be possible. :-) However, this simple trick will allow you to better follow PEP 8 without recurring to pre/post-fixed notations when accessing variable or function members:
Car::Car(unsigned engines) :
Vehicle(4, engines)
{
// use reference instead of pointer ;-)
Car &self = *this;
self.position = 5;
self.movement = 10;
}
Amazing, isn't it ? :-D With just a simple trick we have boosted code readability by one million. PS: how do I highlight "self" ? :-)
Second Letter to Ian
5 years ago
No comments:
Post a Comment