
c++
菩提本無樹-永不放棄
这个作者很懒,什么都没留下…
展开
-
How to initialize struct using member initalizaion list
typedef struct {int sfd;FILE *wfd;int bufSize;int hdrSize;struct iovec *vector;uint8_t *buf;int bytesRecv;int bytesToFeed;unsigned char sockaddr_storage[NI_MAXHOST];}BrcmSocketCtx;原创 2013-10-28 00:07:31 · 682 阅读 · 0 评论 -
pure virtual function can has a function body
轉載自http://stackoverflow.com/questions/5481941/c-pure-virtual-function-have-body Your assumption that pure virtual function cannot be called is absolutely incorrect. When a function is declared转载 2017-04-19 18:48:56 · 365 阅读 · 0 评论 -
Pure Virtual Functions and Abstract Classes in C++
reference http://quiz.geeksforgeeks.org/pure-virtual-functions-and-abstract-classes/1) A class is abstract if it has at least one pure virtual function.2) We can have pointers and references o转载 2017-04-20 11:29:21 · 406 阅读 · 0 评论 -
Multiple Inheritance in C++
#includeusing namespace std;class Person {public: Person(int x) { cout "Person::Person(int ) called" endl; } Person() { cout "Person::Person() called" endl; }}; class Faculty转载 2017-04-20 11:39:46 · 200 阅读 · 0 评论 -
copy constructor
#includeusing namespace std;class A{public: A(){ cout "1";} A(const A &obj){ cout "2";}};class B: virtual A{public: B(){cout "3";} B(const B & obj){cout"4";}};class C: vi转载 2017-04-20 11:42:36 · 317 阅读 · 0 评论 -
Private Destructor
轉載自 http://www.geeksforgeeks.org/private-destructor/Private DestructorPredict the output of following programs.#include using namespace std; class Test{private: ~Test() {}};i转载 2017-05-03 16:03:16 · 341 阅读 · 0 评论 -
How can we restrict dynamic allocation of objects of a class using new?
If we declare new and [] new operators, then the objects cannot be created anywhere (within the class and outside the class) See the following example. We can not allocate an object of type Test usi转载 2017-05-03 16:35:12 · 384 阅读 · 0 评论 -
Some interesting facts about static member functions in C++
Ref http://www.geeksforgeeks.org/some-interesting-facts-about-static-member-functions-in-c/ 1) static member functions do not have this pointer.2) A static member function cannot be virt转载 2017-04-21 12:09:18 · 264 阅读 · 0 评论 -
C++ Can't Overload Static Function with Non-Static Function
Ref http://stackoverflow.com/questions/5365689/c-overload-static-function-with-non-static-functionISO 14882:2003 C++ Standard 13.1/2 – Overloadable declarationsCertain function declarations转载 2017-04-21 18:48:52 · 743 阅读 · 0 评论 -
type-cast operator
轉載自 http://www.cplusplus.com/doc/tutorial/typecasting/The type-cast operator uses a particular syntax: it uses the operator keyword followed by the destination type and an empty set of parentheses转载 2017-05-04 17:14:12 · 384 阅读 · 0 评论 -
conversion constructor
Ref http://quiz.geeksforgeeks.org/c-plus-plus/constructors/ Q16If a class has a constructor which can be called with a single argument, then this constructor becomes conversion constructor because转载 2017-04-25 11:49:35 · 666 阅读 · 0 评论 -
malloc() vs new
轉載自 http://www.geeksforgeeks.org/malloc-vs-new/malloc() vs newFollowing are the differences between malloc() and operator new.1) new calls constructors, while malloc() does not. In fact转载 2017-04-25 11:53:10 · 259 阅读 · 0 评论 -
When do we use Initializer List in C++?
轉載自http://www.geeksforgeeks.org/?p=13797Initializer List is used to initialize data members of a class. The list of members to be initialized is indicated with constructor as a comma separated lis转载 2017-05-26 12:18:14 · 353 阅读 · 0 评论 -
‘this’ pointer in C++
轉載自 http://www.geeksforgeeks.org/this-pointer-in-c/‘this’ pointer in C++The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local v转载 2017-05-26 12:18:49 · 450 阅读 · 0 评论 -
Can we make copy constructor private?
轉載自http://quiz.geeksforgeeks.org/copy-constructor-in-cpp/ Yes, a copy constructor can be made private. When we make a copy constructor private in a class, objects of that class become non-copy转载 2017-04-26 15:02:32 · 268 阅读 · 0 评论 -
What is the use of having destructor as private?
Ref http://stackoverflow.com/questions/631783/what-is-the-use-of-having-destructor-as-privateBasically, any time you want some other class to be responsible for the life cycle of your class' objec转载 2017-04-26 16:26:47 · 236 阅读 · 0 评论 -
c++測試網站
http://quiz.geeksforgeeks.org/转载 2017-04-19 15:06:53 · 292 阅读 · 0 评论 -
c++參考手冊
c++參考手冊http://classfoo.com/ccby/article/acZKb线程支持库(参考手册)http://classfoo.com/ccby/article/GU3rbO转载 2016-11-08 21:26:32 · 542 阅读 · 0 评论 -
Effective c++ 3/e item 15 疑問解惑
轉載自http://stackoverflow.com/questions/4728160/thrown-off-by-functor-syntax-in-effective-cThe firstoperator FontHandle() const {return f;}The secondFontHandle operator()() const {ret转载 2015-06-21 01:25:12 · 634 阅读 · 0 评论 -
assert
例如, 一個假設只接受非空 指針的函數, 可以寫: assert(p != NULL);當程式執行到該行時,若 p != NULL 則程式可以繼續執行;若 p == NULL ,則會秀出維護錯誤訊息的字串,並結束程式。 維護字串包含有:判斷式子、程式檔名及該行的行號。翻译 2013-10-28 00:18:30 · 622 阅读 · 0 评论 -
output operator(也就是<<符號) and std::endl
C++算式由一或多個運算元(operands)和通常會有的一個運算子(operator)組成 每個output operator接收兩個運算元(operands); 左運算元必須是個ostream object, 右運算元則是待印值。outpot operator把右運算元寫至左運算元所示的ostream中 C++的每一個算式都會產生一個結果,通常就是把運算翻译 2013-10-27 23:43:41 · 707 阅读 · 0 评论 -
const
1.const出現在星號左邊,代表被指物是常量。2.const出現在星號右邊,代表被指標自身是常量。 char greeting[] = "Hello";char* p = greeting; //non-const pointer, non-const dataconst char* p = greeting; //non-const pointer, c翻译 2013-10-27 23:50:20 · 533 阅读 · 0 评论 -
(筆記)更快速判斷奇偶數的方法
摘要:一般我們要判斷奇偶數,都會想到用%,其實有更快的方法,不需要動用到除法原理:奇數的數值若以二進位來表示,其最右邊的位元必為1,而偶數最右邊的位元必為0,所以若使用1來與輸入的值作AND運算,因為 1除了最右邊的位元為1之外,其它位元都會是0,所以與輸入數值作AND運算所得的結果,最右邊的位元不是0就是1,其它部份都被0 AND運算遮掉了00000110 6翻译 2013-10-28 00:14:18 · 1073 阅读 · 0 评论 -
C++啟用動態綁定的兩個必須條件
1.只有指名為virtual的成員函式才能進行動態綁定(dynamic binding)2.呼叫動作必須透過「指向base-class type」的reference 或 pointer來進行翻译 2013-10-27 23:39:18 · 591 阅读 · 0 评论 -
class 成員函式可被宣告為const
double avg_price() const;const 成員函式不能修改物件的成員變數keyword const 必須再宣告式跟定義式中出現翻译 2013-10-28 00:08:25 · 495 阅读 · 0 评论 -
三本 OOP 絕佳小書
轉載自 http://jjhou.boolan.com/article00-7.htm转载 2013-10-28 00:09:02 · 605 阅读 · 0 评论 -
char* convert to string and back
void function(const std::string& format){ std::cout return;}int main(int argc, char *argv[]){ int curarg = 1; char * subString = &argv[curarg][strlen("Iam")]; function(原创 2013-10-28 00:10:27 · 741 阅读 · 0 评论 -
android sp wp pointer
轉載自http://developer.51cto.com/art/201001/180894.htm 原文http://www.icepack-linux.com/android-smart-pointer/转载 2013-11-04 22:31:30 · 597 阅读 · 0 评论 -
不錯的C++學習網站
http://cpp.ezbty.org/ 易美C++转载 2013-11-25 10:32:51 · 561 阅读 · 0 评论 -
Google gTest
1.轉載自http://www.cnblogs.com/coderzh/archive/2009/03/31/1426758.html作者:CoderZh(CoderZh的技术博客 - 博客园)微博:http://t.sina.com.cn/coderzh 出处:http://coderzh.cnblogs.com 2.轉載自 http://ro转载 2013-12-18 17:19:45 · 412 阅读 · 0 评论 -
字符串解析出int和bool等类型的值
轉載 http://blog.youkuaiyun.com/jamesfancy/article/details/1543338 从字符串解析出int和bool等类型的值 说到将字符串解析成int,首先想到的一定是atoi、atol等C函数。如果用C++来完成这些工具函数,那就要用到std::istringstream。 除了解析bool值之外,下面这个函数可以解析大部分的转载 2013-12-18 17:19:13 · 795 阅读 · 0 评论 -
c++ thread and mutex(c++11)
http://www.cplusplus.com/reference/mutex/mutex/ http://www.cplusplus.com/reference/thread/转载 2013-12-18 17:19:37 · 495 阅读 · 0 评论 -
effective c++系列勘誤
effective c++勘誤http://aristeia.com/BookErrata/ec++3e-errata.htmlhttp://jjhou.boolan.com/ Scott Meyers勘誤網站http://www.aristeia.com/books.html#errataLinks转载 2013-12-18 17:19:29 · 726 阅读 · 0 评论 -
第一個gtestcode
//filename:firstgtest.c#include string>#include #include "gtest/gtest.h" std::string& UniqueString( std::string &refString ){ std::sort( refString.begin() , refString.end() ); ref转载 2013-12-16 15:11:52 · 454 阅读 · 0 评论 -
Clean Code閱讀筆記
轉載自 http://blog.kent-chiu.com/blog/2013/04/22/clean-code/转载 2013-12-18 17:19:21 · 531 阅读 · 0 评论 -
Can we pass nontype parameters to templates?
轉載自http://quiz.geeksforgeeks.org/templates-cpp/We can pass non-type arguments to templates. Non-type parameters are mainly used for specifying max or min values or any other constant value for a p转载 2017-04-27 15:14:51 · 399 阅读 · 0 评论