in the project i wrote a class that generically services uarts. then i declare 6 objects of that class and hand them configurations for each specific uart.
internally all the objects have a send buffer of data that is still to be sent that gets populated by the object member function.
how can i make an array of function pointers that can point to the same member but of six different objects.
Pointers to member functions are associated with classes, not with objects. You can invoke them on any instance of the class they came from. You only need one pointer to member function in this case.
my project is that i'm making a simple uart router. the micro controller i'm using has 6 uarts. i want it to bring in a packet read it and verify that it's intact then send it to where it needs to go.
the way i designed my project is i have two generic classes, one to receive and one to send. i then declare 6 objects of each and hand them configuration setting to work with the chips hardware.
i'm trying to set up a system where if a message comes in on uart 1 that needs to go to uart 4 after the message is complete and verified the receive object for uart 1 can hand the message over to the send object for uart 4. (the packet length is variable to make things more complicated)
the thought i had was to use an array as a selector. if the address is 4 then
You only need one pointer to member function per class. In fact, &NameOfClass::some_member always gives the same address for the same class and member.
i'm sorry if i'm beating a dead horse but i'm at the limit of my understanding.
if i'm using one pointer how and where would i declare it and how would i make it point to different objects depending on what address the packet needs to go to?