Accept one character and print its next character using class
#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
Comments
Leave a comment