Answer to Question #220659 in C++ for Chirag

Question #220659

Accept one character and print its next character using class


1
Expert's answer
2021-07-27T05:04:02-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS