
C++
歪歪有计划
爱旅行的攻城狮!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
虚函数相关的知识
先上一段代码,简单易懂: #include class Graph{ protected: double x,y; public: Graph(double x,double y){this->x=x;this->y=y;}//---------------------1 ~Graph(){std::cout<<"~Graph "<<std::endl;}//----原创 2014-12-22 00:24:31 · 529 阅读 · 0 评论 -
const的用法
先来一段代码: int main(){ int num = 6; int* p = # const int* p1 = # //const在*号左边 -> 被指物为常量 int* const p2 = # //const在*号右边 -> 指针本身为常量 const int* const p3 = # //被指物和指针本身原创 2014-12-22 09:53:06 · 450 阅读 · 0 评论 -
C++初始化列表
初始化列表:小手段,大回报! 以前我写构造函数是这么写的: class MyString{ string str; public: MyString(string inputStr){ str = inputStr; } }; 但是,看完《Effective C++》,我明白了,赋值(哪怕是赋初值)和初始化是不一样的,上述写法有如下问题: 对原创 2015-01-06 21:49:24 · 387 阅读 · 0 评论 -
如何使得代码在main函数之前/之后执行
main函数是整个C++程序的入口函数,如果程序想要在main函数之前/之后运行,则必须借助全局对象的构造和析构函数。#include class A{ public: A(){std::cout << "A" << std::endl;} ~A(){std::cout << "~A" << std::endl;} }; A a_global = A(); int main原创 2014-12-21 11:43:08 · 590 阅读 · 0 评论 -
友元解析
不废话,先上一段代码: #include class Person{ private: int age; public: Person(int age){ this->age = age; } }; void printAge(Person const &person){ std::cout << person.age << std::end原创 2014-12-25 10:54:16 · 429 阅读 · 0 评论 -
记:由opencv中的waitkey引发的一场血案
opencv中,waitkey这个函数相信大家都很熟悉了,其原型如下:int waitKey(int delay=0) Parameters: delay – Delay in milliseconds. 0 is the special value that means “forever”.一直以来,我都是尊崇着opencv文档中推荐的代码去构建我的工程。最近我又构建了一个需要读入摄像头数据的工原创 2015-03-16 10:07:34 · 10255 阅读 · 2 评论