![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
nealcat
这个作者很懒,什么都没留下…
展开
-
Leetcode 1: Two Sum
Java版本class Solution {public int[] twoSum(int[] nums, int target) { HashMap<Integer,Integer>m =new HashMap<Integer, Integer>(); int[] res=new int[2]; for(int i=0;i<nu...原创 2018-09-05 14:56:01 · 116 阅读 · 0 评论 -
C++单冒号表示继承以及虚函数virtual
#include <iostream>using namespace std;class Base{public: virtual void fun(int x = 0) { cout << "Base::fun(), x = " << x << endl; }};class Derived :...原创 2018-09-05 15:01:19 · 365 阅读 · 0 评论 -
模板函数和模板类简介
模板函数的意义:使用通用类型来定义函数,替换具体类型(如int或double) 譬如有一个交换函数,需要交换两个数值。针对int写一个int函数,针对double写一个double函数。但是这样浪费时间;如果使用全局查找替换,则可能会出现替换错误。(如interval中int被替换)此时模板函数可以被用来解决这个问题:(类似于重载,当然也有重载模板函数)template &lt;clas...原创 2018-09-05 14:57:58 · 235 阅读 · 0 评论 -
操作符重载
#include<iostream>using namespace std;class test{public: int ta, tb;public: test(int a,int b){ ta = a; tb = b;} void tprint(){ cout << ta << "+...原创 2018-09-05 15:38:32 · 72 阅读 · 0 评论