You can define your own environment for a floating listing. I reused the code that was provided in How to center a lstlisting for centering the listing:
\documentclass{scrartcl}
\usepackage{float}% http://ctan.org/pkg/float
\usepackage{listings}
\usepackage{fancybox}
\makeatletter
\newenvironment{CenteredBox}{%
\begin{Sbox}}{% Save the content in a box
\end{Sbox}\centerline{\parbox{\wd\@Sbox}{\TheSbox}}}% And output it centered
\makeatother
% Create new "listing" float, we do not use the "float" option of lstlisting, because we want to use our custom caption
\newfloat{lstfloat}{htbp}{lop}%[section]
\floatname{lstfloat}{Listing}
\newcommand{\mylistoflistings}{\listof{lstfloat}{List of Listings}}
\begin{document}
\begin{lstfloat}
\begin{CenteredBox}
\begin{lstlisting}
#include <iostream.h>
main()
{
cout << "Hello World!";
return 0;
}
\end{lstlisting}
\end{CenteredBox}
\caption{blubb}
\end{lstfloat}
\mylistoflistings
\end{document}
caption
or make a MWE.lstlisting
are centered by default