如何在 LaTex 中编写方法的签名?

How to write the signature of a method in LaTex?

我正在用 LaTex 写一篇关于编程的文章,我需要使用特定格式编写 C++ 方法的签名,只有方法的声明,而不是主体。

例如:

void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 );

我想要这样的东西:

void cvtColor( InputArray src, 
               OutputArray dst, 
               int code, 
               int dstCn=0 
              );

谢谢。

如果您使用:

\medskip
\lstinputlisting[caption={}, label=lst:labeltest, style=input]{code.cpp}

您可以轻松地在 code.cpp 视图中修改您的代码。