看板Programming
标 题Re: 请问 const 的问题
发信站政大狂狷年少 (Thu Nov 23 15:21:06 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!netnews.csie.nctu
※ 引述《[email protected] (... (b) pic)》之铭言:
> 我算是初学者 ^^"
> 请问各位大大 能解释一下const 的用法ㄇ
> 书上写说 防止被更改属性 可是没有举例 是在看不出它的功用 =.=
> 说用类别中privare 还不够 ?? 有点不懂了 (刚碰类别不久的我)
这个问题其实有点大,
总之标在 variable/object 上最起码的保证是,
compiler 侦测得到你想去改它的时候,
就会跟你说 error。
标在 class 的 member function body 之前、参数列之後,
表示在那里面要是 compiler 能侦测到你修改 data member,
就会给你 error,
有个例外状况就是了,
不过这个你目前先不用会。
--
Name: Tseng, Ling-hua E-mail Address:
[email protected]
School: National Tsing Hua University Department: Computer Science
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage:
https://it.muds.net/~uranus
--
╔═══╗ ┼────────────────────────╮
║狂狷 ║ │
* Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮
║ 年少║ ┼╮
< IP:140.119.164.252 > ╰─╮
╚╦═╦╝ ╰
* From:61-230-217-101.dynamic.hinet.net
─╨─╨─ KGBBS ─ ◎ 遨翔"BBS"的狂狷不驯;属於年少的轻狂色彩 ◎