迭代数组C ++

时间:2016-09-13 05:00:20

标签: c++ arrays

新手问题

C ++数组为

class App1{
int end = 3;

public:
int list[end];

void App1::AddInput(){
    for(int i=0; i<end; i++){
        cout << endl << "Enter elements in array: " << endl;
        cin >> n;
        list[i] = n;
    }
}

void App1::display(){
    cout << endl << "Display elements: " <<endl;
    for(int i=0; i<sizeof(list) / sizeof(list[1]); i++){
        cout << i << end;
        cout << list[i];
    }
    cout << endl;
}
}

但这不显示数组内容

1 个答案:

答案 0 :(得分:-1)

您的代码中有一些错误。我已经用在线评论回答了他们,所以你可以按顺序阅读它:

catch (Exception ex)
        {
            string error = Emoji.Blush;

            //for debugging in bot emulator, also output stack trace
            if (activity.ChannelId == "emulator" 
                 || activity.ChannelId == "facebook" //uncomment this line to get stack traces on facebook too
               )
            {
                error += ex.Message + ex.StackTrace;
            }

            //create response activity
            Activity response = activity.CreateReply(error);

            //post back to user
            ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
            await connector.Conversations.ReplyToActivityAsync(response);

        }