新的C ++返回语法有限吗? [英] Is the new C++ return syntax limited?

查看:92
本文介绍了新的C ++返回语法有限吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始了一个新的私人项目,并决定使用更多 C ++ 11 / 14 。所以我也开始使用新的返回语法

I started a new private project and decided to use more C++11/14 this time. So I also started using the new return syntax

auto functionName() -> returnType;

它大部分工作很好,但现在我需要一些错误处理,如何重写这样的东西:

It works for the most part very well, but now I needed some error handling and could not find out how to re-write stuff like this:

virtual const char* what() const noexcept override;

在某些情况下,新的语法不能使用,或者我只是不够聪明到找到正确的顺序?对我来说,重要的是保持一致,所以我希望问题更多在我身边。

with the new syntax. Are there some cases where the new syntax can not be used or am I only not clever enough to find the right order? For me it is important to keep things consistent, so I hope the problem is more on my side.

推荐答案

virtual auto what() const noexcept -> const char * override;

这只是你必须使用的顺序。语法可能不同,可能,但这是我们有。

This is just the order you have to use. The syntax could have been different, probably, but this is what we've got.

这篇关于新的C ++返回语法有限吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆