博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
这是代码:
#include <iostream>
#include 
<stdlib.h>

using namespace std;

typedef 
struct MyStruct{
  
int a;
}
;

void TestConstCase()
{
  
const MyStruct st = {100};
  
  (const_cast
<MyStruct *>(&st))->a--;
  
  cout
<<st.a<<endl;
}


int main(int argc, char *argv[])
{
  TestConstCase();
  
  system(
"PAUSE");    
  
return 0;
}

posted on 2008-01-13 16:25  黑米  阅读(341)  评论(0编辑  收藏  举报