You can use the methods in this way without using a try-catch block:
#include "../cryptopp/base64.h"
std::string encodetxt, decodetxt, uncodedtxt("This is a sample text for base64 coding!");
CryptoPP::StringSource ss1(uncodedtxt, true,
new CryptoPP::Base64Encoder( new CryptoPP::StringSink(encodetxt) ));
CryptoPP::StringSource ss2(encodetxt, true,
new CryptoPP::Base64Decoder( new CryptoPP::StringSink(decodetxt) ));
The coding is based on RFC4648, additional code is required for a web safe alphabet according to the documentation.