自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 资源 (2)
  • 收藏
  • 关注

原创 private

private:When preceding a list of class members, the private keyword specifies that those members are accessible only from member functions and friends of the class. This applies to all members decla

2013-08-29 23:30:09 775

原创 String类:构造函数,拷贝构造函数

#include #include using namespace std;class String{public: String(const char * str = NULL); //默认参数只需在函数声明时注明,函数定义时不需要 String(const String &other); String & operator=(const String &other); ~S

2013-08-27 08:18:23 748

转载 delete delete[]

http://stackoverflow.com/questions/4255598/delete-vs-deleteFrom the standard (5.3.5/2) :In the first alternative (delete object), the value of the operand of delete shall be a pointer to a

2013-08-27 07:43:09 714

原创 C++ Primer 笔记--13章:定义值型类

要使指针成员表现得像一个值,复制 HasPtr 对象时必须复制指针所指向的对象。复制构造函数不再复制指针,它将分配一个新的 int 对象,并初始化该对象以保存与被复制对象相同的值。每个对象都保存属于自己的 int 值的不同副本。因为每个对象保存自己的副本,所以析构函数将无条件删除指针。赋值操作符不需要分配新对象,它只是必须记得给其指针所指向的对象赋新值,而不是给指针本身赋值。/* *

2013-08-26 23:14:59 664

原创 C++ Primer 笔记-- 13 章: 智能指针类

除了使指针成员与指针完全相同之外,另一种方法是定义所谓的智能指针类。智能指针除了增加功能外,其行为像普通指针一样。本例中让智能指针负责删除共享对象。用户将动态分配一个对象并将该对象的地址传给新的 HasPtr类。用户仍然可以通过普通指针访问对象,但绝不能删除指针。HasPtr 类将保证在撤销指向对象的最后一个 HasPtr 对象时删除对象。新的 HasPtr 类需要一个析构函数来删除指针,但是

2013-08-26 07:42:45 714 1

原创 C++ Primer 笔记--13章:复制控制

包含指针的类需要特别注意复制控制,原因是复制指针时只复制指针的地址,而不会复制指针指向的对象。将一个指针复制到另一个指针时,两个指针指向同一个对象,此时可能使用任一指针改变这一对象。类似的,很可能一个指针删除了一对象时,另一指针的用户还认为该对象仍然存在。一个带指针成员的简单类://class that has a pointer member that behave like a p

2013-08-25 11:00:30 503

转载 default constructor

https://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr376.htmA default constructor is a constructor that either has no parameters,

2013-08-19 22:05:57 1882

转载 前向声明(forward declaration)

C++ primer 笔记可以声明一个类而不定义它:class Screen;  //declaration of the Screen class这个声明有时称为前向声明(forward declaration),在程序中 引入了类类型Screen。在声明之后、定义之前,类Screen是一个不完全类型(incomplete type),即已知Screen是一个类型,但不知道包含哪些成

2013-08-18 00:18:10 1359

转载 给定一个十进制整数N,求出从1到N的所有整数中出现”1”的个数

//给定一个十进制整数N,求出从1到N的所有整数中出现”1”的个数。int cal_num_of_1(int n){ int count = 0; int temp; for(int i = 1; i<n+1; i++) { temp = i; while(temp>0) { if(temp%10 == 1) { count++; } tem

2013-08-17 17:56:08 1424

转载 找到第二大的数

int find_sec_max(int *a, int size){ int max, sec_max; if(a[0] > a[1]) { max = a[0]; sec_max = a[1]; } else { max = a[1]; sec_max = a[0]; } for(int i=2; i < size; i++) { if(a[i] >

2013-08-17 17:50:38 591

转载 用递归实现n是2的几次方

//用递归实现n是2的几次方int log2(int n){ if(!(n&(n-1))) { if(1 == n) { return 0; } else { return 1+log2(n>>1); } } else { return 0; }}

2013-08-17 17:49:31 1976

原创 求两个数的最大值

#include int cal_max(const int &a, const int &b){ int c; c = (a+b+abs(a-b))/2; return c;}int cal_max_2(const int &a, const int &b){ bool c=false; c = (bool)((unsigned int)(a-b) >> (sizeof(

2013-08-17 17:48:18 1340

原创 冒泡排序

//升序排列;先确定最大的数void bubble_sort(int a[], int size){ bool swapped = false; for(int i = 0; i < size-1 ; i++) //外层进行size-1次循环,如有10个数,外层进行进行9次循环 { swapped = false; for(int j=0; j < size-1-i ; j++)

2013-08-17 17:46:14 590

原创 tyradyne interivew

/* * teradyne.h * * Created on: 2013-8-11 * Author: Administrator */#ifndef TERADYNE_H_#define TERADYNE_H_#include #include using namespace std;//给定一个表达式,判断'('和')'是否配对,如“ )+3(”是

2013-08-11 01:05:18 616

原创 alps interview

/* * alps.h * * Created on: 2013-8-10 * Author: Administrator */#ifndef ALPS_H_#define ALPS_H_#include #include using namespace std;//已知4个数字:1,2,3,4,输出它们组合成的所有三位数,且这个三位数的数字没有重复vo

2013-08-11 00:13:16 609

原创 const

/* * myconst.h * *  Created on: 2013-8-10 *      Author: Administrator */#ifndef MYCONST_H_#define MYCONST_H_#include #include #include #include using namespace std;

2013-08-10 18:35:54 483

转载 virtual function

http://en.wikipedia.org/wiki/Virtual_functionThe concept of the virtualfunction solves the following problem:In OOPwhen a derived class inherits from a base class, an object of the derived class

2013-08-08 23:26:08 509

集成运算放大器构成交流放大电路的分析和设计

集成运算放大器构成交流放大电路的分析和设计集成运算放大器构成交流放大电路的分析和设计

2010-06-25

电解电容使用指南,教你如何使用电解电容

铝电解电容器基本的电性能电容器的电容量由测量交流容量时所呈现的阻抗决定

2010-06-25

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除