ChinaUnix.net
相关文章推荐:

const uchar*转换为char*

本帖最后由 ankhman 于 2011-12-15 19:58 编辑 /home/ankh/qframework/QfwSeismic_lib-build-desktop-Qt_4_8_0_in_PATH__4_8_0__Debug/../QfwSeismic/QfwSeismicXml/QfwRgbColorFusionModelDom.cpp:49: error: passing ‘const QfwRgbColorFusionModelDom’ as ‘this’ argument of ‘virtual const QfwAbstractHorizonModel* QfwRgbColorFusionModelDom::findHorizonModel(QString, const QList&)’...

by ankhman - C/C++ - 2011-12-15 21:55:56 阅读(1165) 回复(1)

相关讨论

有如下类 class String {public: String(const char *initValue = ""); String(const String &rhs); ~String(); String& operator=(const String &rhs); const char& operator[](int index) const; char& operator[](int index);......}; 和如下语句 String s; .. ... cout <

by blizzard213 - C/C++ - 2008-07-17 19:17:34 阅读(2256) 回复(8)

char a[]="nice day"; char* const pc=a; //pc="hello world";//cannot change the pc pointer address a[0]='w'; cout<const pc="hello hell"; //pc="hello world";//cannot change the pc pointer address *pc='w'; cout<

by dutysmart - C/C++ - 2013-07-12 15:10:37 阅读(1227) 回复(3)

const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); 1、第一个const是什么意思; 2、src指向的内存为只读,是src指向的第一个char型为只读,还是p指向的字符串为只读啊。 小弟比较菜,望大家指点

by lilikoo - C/C++ - 2010-10-09 22:27:51 阅读(2215) 回复(12)

#include #include using std::cout; using std::endl; using std::cin; using std::string; int main() { string mystr1("TEST"); const char *ptr; //请问大家这里为什么一定要定义成const才行呢?去掉const 就编译通不过. ptr = mystr1.c_str(); cout<

by hxl - C/C++ - 2010-04-20 17:37:10 阅读(1350) 回复(7)

class example { public: operator const TInt() const { return ret; } TInt ret; } 上面代码中两个const的意义,help;

by woxinfeixiang - C/C++ - 2009-08-04 18:57:03 阅读(1054) 回复(3)

#include using std::string; class A { public:     inline const string& get()     {         return m_str;     } private:     string m_str; }; class B { public:     void fun(const A& a)     {       &n...

by zhongyj - C/C++ - 2008-10-31 16:19:05 阅读(1408) 回复(2)

C/C++中const用的很多,但是总让人犯迷糊。总结下它的用法,如果说的不对还请指正。 1、const修饰的后的对象不是一个常量,它只表示修饰的对象是个只读的对象。 可以用下面的方法证明: const int a = 1; switch(i) { case a: ... break; case 2: ... break; default: ... break; } 如果i等于1,不会执行case a: 后面的语句。 2、const修饰后的对象,默认的表示此对象只能在该文件中用。 如:const int a = 1; 等同...

by liaoweijun - C/C++ - 2008-07-24 15:59:02 阅读(11224) 回复(49)

理解const 首先,为什么const。 一个很简单的例子,如何有人传给你一堆数据,要你根据数据返回一个处理的结果,比如做CRC校验。 unsigned int do_crc(void *buf, int len); 你做完之后,只要告诉他CRC是对还是错就可以了。 但是,如果buf里的数据经过几次处理后,发现给改动了,但是又不知道是谁改动的,问题就出现了,你有口无凭。 但是,只要做个小小的改动: unsigned int do_crc(const void *buf, int len); 这样就没可能是...

by zhoubaozhou - Linux文档专区 - 2008-07-09 17:08:04 阅读(698) 回复(0)

#include "stdio.h" void main() { const int i=30; int *p; p=&i; *p=50; printf("%d",i); } 运行后i的值为50;各位指教一下,到底对不?

by lplplplp - C/C++ - 2008-02-29 13:19:48 阅读(2548) 回复(11)

再程序中使用const有什么好处呢?能使程序减少bug是吗?

by zhn636 - C/C++ - 2007-09-04 17:42:17 阅读(2661) 回复(11)