Created Tue, 08 Mar 2016 03:48:45 +0000 by FredCailloux
Tue, 08 Mar 2016 03:48:45 +0000
Hello Majenko, In my previous question "re#define before or after #include" you show a piece of code example to explain some strategy to pass an object DSPI in a class.
class foo {
private:
DSPI *_spi;
public:
foo(DSPI &spi) : _spi(&spi) {}
foo(DSPI *spi) : _spi(spi) {}
void begin() {
_spi->begin();
}
};
DSPI2 spi;
foo MyFoo(spi);
In here you show the line DSPI *_spi: Can you explain quickly why the underscore ? Would it make a difference if the line was DSPI *spi; or DSPI *aspi; ? Is the underscore part of the variable name or does it have a specific significance ?
Tue, 08 Mar 2016 08:45:04 +0000
It's purely a convention on my part. I name my class member variables in that way so I can tell them apart from local or global variables at a glance.
Sent from my SM-T555 using Tapatalk