Constructor with Parameters

#include <iostream>
using namespace std;

class UART {
private:
    int baud;
    char parity;
public:
    UART() = default;
    UART(int b, char p) : baud(b), parity(p)
        { cout << "UART initialized with baud=" << baud << ", parity=" << parity << endl; }
};

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

Input

Expected Output

UART initialized with baud=9600, parity=N