iOS 裡const在修飾對象時候的用法

來源:互聯網
上載者:User

標籤:bsp   gpo   其他   color   就是   nss   span   class   用法   

/* ---------- const NSString *str1 = @"123" ----------| 0x123456  str  --- 0x654321  || 123 ---- 0x654321 | // const 修飾的是 *str, 而*str 是值, 所以const 修飾的就是值123|           str  --- 0x654221  || ads ---- 0x654221 | // 因為const 修飾的是值 所以 指標str 還是可變的(可以指向其他值) ---------- NSString const *str2 = @"456" ----------| 0x123464  str2  --- 0x654311 || 456 ---- 0x654311 | // 與上面同理|           str2  --- 0x654211 || zxc ---- 0x654211 | ---------- NSString* const str3 = @"789" ----------| 0x123478  str3  --- 0x654301 || 789 ---- 0x654301 | // const 修飾的是 str3, 而str3 是指標(指向的是值的地址),|                              ||                   |    所以const 修飾的就是值789 的地址值| 0x123478  str3  --- 0x654301 || qwe ---- 0x654201 | // 因為const 修飾的是指標(指向的是值的地址)|                              ||                   |    所以 指標str3 是不可變的(不可以指向其他地址)------------------------------------------------------*/

 

iOS 裡const在修飾對象時候的用法

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.