The C++ programming language is made to be a very efficient language. As such, the language itself (i.e. without including any libraries) can't really do that much, basically you can only get input through argc
and argv
and you can only send output through the return value.
The standard library helps a lot, giving us access things such as files, allowing us to do a lot more. As console developers it also allows us to use the standard input and the standard output through std::cin and std::cout (also the standard error stream through std::cerr but we usually hope nothing will be written to it). Since we get access to those tools through streams, to our program there's no such thing as "The second line from the top of the console", it's only a long line of letters. As such it's absolutely impossible to do this using only C++ and the standard library.
What about windows then? It can do it! Yes, but that's a windows thing, not a C++ thing (it's being a while since I used windows but I remember it sometimes causing issues with streams), third-parties windows-compatible console emulators can function exactly like Linux terminals (and I guess Linux terminals could work just like windows, I just haven't seen one yet) so we need something to guaranty us this behavior.
Thankfully, one of the main advantage of C/C++ is the sheer number of libraries available to us. An big part of C++ programs don't even use a console anymore, bypassing completely the issue.
What I'd recommend is to find a good library (I sometimes use ncurses although I think it's Linux-only and probably a bit too feature full for your usecase) and use it to control the cursor to make it do what you want