#include <iostream>
#include <cstdint>
using namespace std;
class UARTHardware {
private:
int baud;
public:
// Implement constructor to store baud rate
UARTHardware(int baudRate): baud(baudRate){}
// Delete copy constructor
UARTHardware(const UARTHardware&) = delete;
// Delete copy assignment operator
UARTHardware& operator=(const UARTHardware other) = delete; //this is required when there is plain assignment; copy = uart
void sendByte(uint8_t value) const {
cout << "TX: " << (int)value;
}
};
int main() {
int baudRate;
cin >> baudRate;
int temp;
cin >> temp;
uint8_t byteToSend = (uint8_t)temp;
UARTHardware uart(baudRate);
// Demonstration (must not compile if uncommented)
//UARTHardware copy = uart;
uart.sendByte(byteToSend);
return 0;
}
Input
9600 65
Expected Output
TX: 65