Question #220659

Accept one character and print its next character using class


Expert's answer

#include <iostream>

using namespace std;

class NextChar
{
private:
    char c;
public:
    NextChar(char c) : c(c) {}

    void next() {
        cout << "Next character is: " << (char) (c+1) << '\n';
    }
};

int main()
{
    char c = 'A';
    NextChar nxt = NextChar(c);
    nxt.next();

    return 0;
}

Output:
Next character is: B

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS