Caesar cipher implementation in C++
You can accept arguments from the command line.

You don't need to differentiate between decode and encode, you can simply provide negative shift.

You can hide the big lambda into a char -&gt; char function.

You actually don't need the string -&gt; string nor vector -&gt; vector implementations.

encodeStr is a terrible name :)

You can leverage the char -&gt; char implementation and copy istream_iterator&lt;char&gt; to ostream_iterator&lt;char&gt; char by char, and doing it over std::cin and std::cout will give you the ability to change the files as needed (through pipes) or use standard input / output by default.

#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;sstream&gt;

const unsigned char caesar_range = 'Z' - 'A' + 1;

char caesar_cipher(char c, int shift)
{
    char offset;
    if (c &gt;= 'a' &amp;&amp; c &lt;= 'z') offset = 'a';
    else if (c &gt;= 'A' &amp;&amp; c &lt;= 'Z') offset = 'A';
    else return c;

    shift = shift % caesar_range;
    auto base = c - offset + shift;
    if (base &lt; 0) {
        base = caesar_range + base;
    }
    return base % caesar_range + offset; 
}

void caesar_usage()
{
    std::cout &lt;&lt; "Usage caesar &lt;shift&gt;\n";
    std::cout &lt;&lt; "\tshift must be integer and providing -shift decodes string encoded with shift.\n";
}

int main(int argc, char *argv[])
{
    if (argc != 2) {
        caesar_usage();
        return EXIT_FAILURE;
    }

    int shift;
    std::stringstream ss(argv[1], std::ios_base::in);
    ss &gt;&gt; shift;
    if (ss.fail() || !ss.eof()) {
        caesar_usage();
        return EXIT_FAILURE;
    }

    // turn off white space skipping
    std::cin &gt;&gt; std::noskipws;

    std::transform(
        std::istream_iterator&lt;char&gt;(std::cin),
        std::istream_iterator&lt;char&gt;(),
        std::ostream_iterator&lt;char&gt;(std::cout), 
        [&amp;](char c) -&gt; char {
          return caesar_cipher(c, shift);
        }
    );

    return EXIT_SUCCESS;
}


Encode | decode:
./caesar 5 &lt;in.txt | ./caesar -5