
C++
文章平均质量分 57
普通网友
这个作者很懒,什么都没留下…
展开
-
在一个表达示中重复使用 i++或++i的问题;
今天在论坛刚看到在一个表达示中重复使用的问题。的确是我以前不知道的,又学了点知识。先是 :int n = 5;std::cout 输出是:7, 7,不是6,7也不是7,6;再试了试:std::cout 输出是:MS.VS2005 和 g++ 是不一致的,说明是一个UB;std::cout 输出也不一致。原创 2007-07-20 20:23:00 · 502 阅读 · 0 评论 -
[20] Inheritance — virtual functions
FAQs in section [20]: [20.1] What is a "virtual member function"? [20.2] How can C++ achieve dynamic binding yet also static typing? [20.3] Whats the difference between how virtual a转载 2007-05-31 22:53:00 · 969 阅读 · 0 评论 -
[21] Inheritance — proper inheritance and substitutability
(Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [21]: [21.1] Should I hide member functions that were public in my base class? [21.2]转载 2007-05-31 22:53:00 · 863 阅读 · 0 评论 -
[22] Inheritance — abstract base classes (ABCs)
(Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [22]: [22.1] Whats the big deal of separating interface from implementation? [22.2] H转载 2007-05-31 22:54:00 · 539 阅读 · 0 评论 -
[24] Inheritance — private and protected inheritance
(Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [24]: [24.1] How do you express "private inheritance"? [24.2] How are "private inherit转载 2007-05-31 22:55:00 · 670 阅读 · 0 评论 -
[25] Inheritance — multiple and virtual inheritance
FAQs in section [25]: [25.1] How is this section organized? [25.2] Ive been told that I should never use multiple inheritance. Is that right? [25.3] So there are times when multiple转载 2007-05-31 22:56:00 · 532 阅读 · 0 评论 -
[17] Exceptions and error handling
(Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [17]: [17.1] What are some ways try / catch / throw can improve software quality? [17.转载 2007-05-31 22:57:00 · 579 阅读 · 0 评论 -
一道非常简单的C语言指针题目,能做对吗?
#include int main() { int* p = (int*)1000; int* q = (int*)2000; printf("%d", p - q); return 0;}结果输出为什么?如果能答对,说明你C的指针基本学到位了。答案请后住看。有不理解的可以回复交流。-250原创 2007-05-31 23:01:00 · 914 阅读 · 5 评论 -
重载自己的 new / delete
My Rant on C++s operator newby David Mazières Abstract These are some notes I have on C++s operator new. Basically, I find its syntax downright hateful, and really wish the language had d转载 2007-06-05 23:10:00 · 2045 阅读 · 0 评论 -
C++ Refrence to the temp return value
Question about reference of the function return object. class A { public: std::string getString() const { return str_; } private: std::原创 2007-06-04 20:32:00 · 745 阅读 · 0 评论 -
MALLOC 和new /delete 区别
When new has an object, space for the object is not only allocated but the objects constructor is called. And similarly when delete as an object, the objects destructor is called before the me转载 2007-06-10 12:25:00 · 1019 阅读 · 3 评论 -
被误解的C++
我不是要否定C,更不是要挑起口水,只是要纠正不断被讹传的对C++认识的误区。1.C++不是C的超集C++沿袭了C很多的优良传统,但不仅仅是Object in C。从设计泛型开始就和C走不通道路,BJ一直强调C++是一门新的语言。C++与C只能说比较亲。2.C++不是OOP语言C++是一个多泛型语言,可以选择OO,PO(process oriented),GP,(generic pro转载 2008-02-19 14:59:00 · 515 阅读 · 0 评论 -
段错误bug的调试
段错误bug的调试我们在用C/C++语言写程序的时侯,内存管理的绝大部分工作都是需要我们来做的。实际上,内存管理是一个比较繁琐的工作,无论你多高明,经验多丰富,难免会在此处犯些小错误,而通常这些错误又是那么的浅显而易于消除。但是手工“除虫”(debug),往往是效率低下且让人厌烦的,本文将就"段错误"这个内存访问越界的错误谈谈如何快速定位这些"段错转载 2008-08-07 10:31:00 · 947 阅读 · 0 评论 -
[34] Container classes
FAQs in section [34]: [34.1] Why should I use container classes rather than simple arrays? [34.2] How can I make a perl-like associative array in C++? guaranteed to be contiguous?" h转载 2007-05-31 22:50:00 · 705 阅读 · 0 评论 -
[13] Operator overloading
FAQs in section [13]: [13.1] Whats the deal with operator overloading? [13.2] What are the benefits of operator overloading? [13.3] What are some examples of operator overloading?转载 2007-05-31 22:43:00 · 1072 阅读 · 0 评论 -
Input/output via and
FAQs in section [15]:[15.1] Why should I use instead of the traditional ?Increase type safety, reduce errors, allow extensibility, and provide inheritability. printf() is arguably not broke转载 2007-05-31 22:30:00 · 1065 阅读 · 0 评论 -
在构造函数中调用其它的构造函数
class ConstructTest{public: ConstructTest() { //do some initialize data _data = 100; } ConstructTest(const char * szData) { new(this) ConstructTest(); //do other things. }private: int _data;};原创 2007-07-31 14:46:00 · 515 阅读 · 0 评论 -
Construct Named Parameter Idiom
Sometimes, construct a object has many option parameter. The traditional solution is to write a construct using many parameters and set paramter which may be changed most possible at first and set原创 2007-07-31 15:24:00 · 579 阅读 · 0 评论 -
create temporaries using a default constructor
Try to compile codes which demonstrate bolew#include iostream>class Bar {public: Bar() {}};class Foo {public: Foo(const Bar& b) {} void blah() { std::cout "Foo::blah() called.";原创 2007-07-31 16:17:00 · 598 阅读 · 0 评论 -
operator override of a Matrix class
Copy from FAQS:Use operator() rather than operator[]. When you have multiple subscripts, the cleanest way to do it is with operator() rather thanwith operator[]. The reason is that operator[] alway原创 2007-07-31 16:54:00 · 817 阅读 · 0 评论 -
access or changed value using ++i and i++ in one expression
see the code:#includeiostream>int main(){ int a=0; std::cout "a++, a result :" a++ " " a std::endl; a = 0; std::cout "a, a++ result :" a " " a++ std::endl; a = 0; std原创 2007-08-01 14:40:00 · 544 阅读 · 0 评论 -
premature optimization
在性能上下面的二个函数有什么不同呢?哪个运行效率更高呢?double test() { double a,b,c; for(int i=0; i a = i*10; b = a-i; c += a*b; } return c; } or: double原创 2007-05-19 09:01:00 · 562 阅读 · 0 评论 -
Optimization: Your Worst Enemy
Now theres a title to grab your attention! But Im serious!First, a little background on me: my PhD was one of the earliest on the automatic creation of optimizing compilers from formal machine des原创 2007-05-19 09:32:00 · 561 阅读 · 0 评论 -
[27] Coding standards
FAQs in section [27]: [27.1] What are some good C++ coding standards? [27.2] Are coding standards necessary? Are they sufficient? [27.3] Should our organization determine coding stand转载 2007-05-31 22:41:00 · 1041 阅读 · 0 评论 -
[33] Pointers to member functions
FAQs in section [33]: [33.1] Is the type of "pointer-to-member-function" different from "pointer-to-function"? [33.2] How do I pass a pointer-to-member-function to a signal handler, X even转载 2007-05-31 22:46:00 · 772 阅读 · 0 评论 -
[35] Templates
FAQs in section [35]: [35.1] Whats the idea behind templates? [35.2] Whats the syntax / semantics for a "class template"? [35.3] Whats the syntax / semantics for a "function templa转载 2007-05-31 22:51:00 · 614 阅读 · 0 评论 -
[23] Inheritance — what your mother never told you
[23] Inheritance — what your mother never told you Updated! (Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [23]: [23.1] Is it okay for a转载 2007-05-31 22:54:00 · 583 阅读 · 0 评论 -
[26] Built-in / intrinsic / primitive data types
(Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [26]: [26.1] Can sizeof(char) be 2 on some machines? For example, what about double-byte ch转载 2007-05-31 22:57:00 · 664 阅读 · 0 评论 -
[5] Netiquette when posting to comp.lang.c++
[5] Netiquette when posting to comp.lang.c++ (Part of C++ FAQ Lite, Copyright © 1991-2006, Marshall Cline, cline@parashift.com)FAQs in section [5]: [5.1] What does IMHO mean? (or IMO, IMNSH转载 2007-06-02 23:36:00 · 1105 阅读 · 1 评论 -
(转)如何通过CMPP短信网关下发wap push
如何通过CMPP短信网关下发wap push 折腾了几天wap push,终于有个结论。通过CMPP短信网关下发已测试出技术实现没问题, 而用同样的方式给联通的SGIP短信网关发送,返回一个socket被关闭的信号,估计是做了屏蔽。 致电联通技术负责人,果然福建地区把wap push都封住了,不但是短信网关,连PPG都不行。看 来联通也明白自己的平台管理不善,容易让不法分子钻空子原创 2009-05-30 17:08:00 · 2118 阅读 · 0 评论