Some questions about initializing parameter list in C + +

Source: Internet
Author: User

1 /*2 1. Members are initialized in the order in which they appear in the class, rather than in the order in which they appear in the initialization list!3 a good habit is to initialize in the order in which the members are defined. 4 2. Array members are incorrect in the initialization parameter list5 */6#include <iostream>7#include <cstdio>8#include <cstring>9#include <algorithm>Ten  One using namespacestd; A  -  - structnode{ the     intI, J; -     intnum[ A];  -     //node (int x): j (x), I (j) {}//wrong initialization. -     /* + the value of I here is undefined because although J appears in the initialization list in front of I, but I is defined before J, I is initialized first, - while I was initialized by J, J was not initialized at this point, so the value of I was undefined and then the J was initialized.  +     */ A     //node (): Num[1] (1), num[2] (3) {}//the wrong writing atNodeintx): I (x), J (i) {} -     void  out(){ -cout<<i<<" "<<j<<Endl; -     } - };  -  in intMain () { -Node A (4); toA. out(); +     return 0; -}

Some questions about initializing parameter list in C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.