Constructor with Parameters

#include <iostream>
using namespace std;

class UART {
public:
    UART(int baudRate, char parity):baudRate(baudRate), parity(parity)
    {
        std::cout << "UART initialized with baud=" << baudRate << ", parity=" << parity << "\n";
    }
private:
    int baudRate;
    char parity;
};

int main() {
    UART u(9600, 'N');
    return 0;
}
Upvote
Downvote
Loading...

Input

Expected Output

UART initialized with baud=9600, parity=N