2013年10月19日

析构函数 异常 [转]

摘要: more effective c++提出两点理由(析构函数不能抛出异常的理由):1)如果析构函数抛出异常,则异常点之后的程序不会执行,如果析构函数在异常点之后执行了某些必要的动作比如释放某些资源,则这些动作不会执行,会造成诸如资源泄漏的问题。2)通常异常发生时,c++的机制会调用已经构造对象的析构函数来释放资源,此时若析构函数本身也抛出异常,则前一个异常尚未处理,又有新的异常,会造成程序崩溃的问题。那么当无法保证在析构函数中不发生异常时, 该怎么办?其实还是有很好办法来解决的。那就是把异常完全封装在析构函数内部,决不让异常抛出函数之外。这是一种非常简单,也非常有效的方法。 ~ClassName 阅读全文

posted @ 2013-10-19 23:36 風逍遥 阅读(153) 评论(0) 推荐(0) 编辑

[LeetCode] Reverse Integer

摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!If the integer's last digit is 0, what should 阅读全文

posted @ 2013-10-19 23:32 風逍遥 阅读(134) 评论(0) 推荐(0) 编辑

[LeetCode] Two Sum

摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文

posted @ 2013-10-19 23:31 風逍遥 阅读(146) 评论(0) 推荐(0) 编辑

[LeetCode] Same Tree

摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value./*** Definition for binary tree* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val 阅读全文

posted @ 2013-10-19 23:30 風逍遥 阅读(105) 评论(0) 推荐(0) 编辑

[LeetCode] Sum Root to Leaf Numbers

摘要: Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3The root-to-leaf path1->2represents the number12.T 阅读全文

posted @ 2013-10-19 23:26 風逍遥 阅读(113) 评论(0) 推荐(0) 编辑

[LeetCode] Single Number II

摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?class Solution {public: int singleNumber(int A[], int n) { // Note: The Solution object is i 阅读全文

posted @ 2013-10-19 23:25 風逍遥 阅读(130) 评论(0) 推荐(0) 编辑

[LeetCode] Single Number

摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?前几天一个哥们强烈推荐了这个LeetCode OJ 试了几道题,觉得这个网站真的屌炸天。决定把这些题目都做一下,尽量做完。实在不会的就借鉴别人的结题报告好了。思路:简单的异或操作即可。class 阅读全文

posted @ 2013-10-19 23:19 風逍遥 阅读(144) 评论(0) 推荐(0) 编辑

2013年5月29日

pyrDown和pyrUp

摘要: pyrDown函数原型:void pyrDown(InputArray src, OutputArray dst, const Size& dstsize=Size(), int border-Type=BORDER_DEFAULT)参数:src-输入图像dst-输出图像,有指定尺寸,和src类型一致dstsize-输出图像的尺寸,默认值为Size((src.cols+1)/2,(src.rows+1)/2),但是在任何情况下需要满足以下条件:|dstsize.width*2-src:cols| ≤2|dstsize.height*2-src:rows| ≤2pyrUpvoid 阅读全文

posted @ 2013-05-29 11:15 風逍遥 阅读(451) 评论(0) 推荐(0) 编辑

第n+1个博客

摘要: 这是我第n+1个博客了,具体这n等于多少我也不知道了。我在很多地方开过很多博客。多得数不过来。每次新开一个博客,我都会写上这是第n+1个博客。希望这个好用,够用。喜欢计算机和互联网。最近在学习C++和opencv,菜鸟一个。偶尔自己也写一点代码,但是经常回去再找就找不到了。因为电脑实在太乱了。有时候在寝室写代码,有时候在实验室写。经常弄混找不到。以后学习了什么代码都写到这里来。也会分享,转载一些别人的代码。与大家共同学习,祝大家开心。关于我本人嘛:老和山职业技术学院CS小硕一枚。这里的牛人很多,我只是菜鸟中的菜鸟,希望在这里记录自己的学习和生活。主要是学习。嘿嘿~~~ 阅读全文

posted @ 2013-05-29 09:53 風逍遥 阅读(112) 评论(0) 推荐(0) 编辑

导航