Initialisation and assignment

后端 未结 6 2209
不思量自难忘°
不思量自难忘° 2020-11-29 04:16

What EXACTLY is the difference between INITIALIZATION and ASSIGNMENT ?

PS : If possible please give examples in C and C++ , specifically .

Actually , I was

6条回答
  •  萌比男神i
    2020-11-29 04:39

    Initialisation: giving an object an initial value:

    int a(0);
    int b = 2;
    int c = a;
    int d(c);
    std::vector e;
    

    Assignment: assigning a new value to an object:

    a = b;
    b = 5;
    c = a;
    d = 2;
    

提交回复
热议问题