I wish to redirect standard error of one command to standard input of another command like
g++ filename.cpp 'redirection' less
You can use pipe to do that
command1 2>&1 >/dev/null | command2
It will redirect the standard error stream of the first command to the standard input stream of the second command while discarding the standard output stream of command1.
The redirections are done in order:
command1 2>&1 will redirect file descriptor 2 (standard error) to wherever file descriptor 1 (standard output) is connected.
>/dev/null (the same as 1>/dev/null) will redirect standard output to /dev/null.
In your case:
g++ filename.cpp 2>&1 >/dev/null | less