In C++ creating and manipulating a mutable stack of characters is rather simple. I use a built-in standard data type (std::string), use a push and pop fuctions that comes with it and can directly print the results. None of this requires creating additional classes or functions.
#include <iostream>
int main()
{
std::string path {};
path.push_back('L');
path.push_back('R');
path.pop_back();
std::cout << path;
}
Produces:
L
What is Kotlin for C++ push_back()
and pop_back()
as a stack of characters?
The question is not how can I implement these as member functions in Kotlin.