??? 06/19/07 22:26 Read: times |
#141057 - more OO in C Responding to: ???'s previous message |
Russ,
To add to what you're doing ... If you put your UART stuff all in its own source file (uart.c, anyone), and declare any globals in that file as static, you effectively hide them from the outside world. They become private data members of the "uart" class. Of course you have to write accessor methods, along the lines of UartIsFIFOFull() and such. In cases where your constraints preclude a function call, since after all, simply checking a global status bit is a lot faster and smaller than the overhead of a function call, you might rethink the approach. However, in many cases, the encapsulation is very convenient. Along these lines, you can implement both private and public member functions. Function declarations for the public methods go in the uart.h file and the function declarations for private methods go at the top of uart.c (and should be declared as static). I don't think I'd go so far as to deal with pointers to functions. -a |
Topic | Author | Date |
Object Oriented Programming in C | 01/01/70 00:00 | |
Make it ugly. :) | 01/01/70 00:00 | |
Ugly and scary!!! | 01/01/70 00:00 | |
Logical approach | 01/01/70 00:00 | |
Wasn\\\'t Natural For Me | 01/01/70 00:00 | |
Nice post Russ. | 01/01/70 00:00 | |
Agree 100% | 01/01/70 00:00 | |
OOP in C | 01/01/70 00:00 | |
more OO in C | 01/01/70 00:00 | |
All good hints, for sure | 01/01/70 00:00 |