小编Ang*_*hoi的帖子

如何在执行期间终止具有结构类型的自动功能(或从中返回)?

如何在执行期间以结构返回类型终止“自动”类型函数?

当满足以下某些条件时,我想对自动功能“ Func”(而不是整个程序)进行转义:

#include "stdafx.h"
#include <vector>
#include <tchar.h>
#include <iostream>

using namespace std;

auto Func(int B, vector<int> A) {
    for (int a = 0; a < B; a++)
    {
        A.push_back(a);
        if (a == 2)
        {
            cout << " Terminate Func! " << endl;
            // return; I want to terminate 'Func' at this point  
        }
    }

    struct result { vector <int> A; int B; };
    return result{ A, B };
}

int _tmain(int argc, _TCHAR* argv[])
{

    vector<int> A;
    int …
Run Code Online (Sandbox Code Playgroud)

c++ return-type auto

6
推荐指数
1
解决办法
120
查看次数

标签 统计

auto ×1

c++ ×1

return-type ×1