代码改变世界

Microsoft Word已停止工作的解决办法

2012-07-01 23:47 by youxin, 1493 阅读, 0 推荐, 收藏,
摘要:一些朋友可能在使用Word的时候遇到过“Microsoft Word已停止工作”的问题,当出现这个问题以后,无法正常打开Word进行编辑,即使重装Office也不能解决。一般来说这个问题都是由于Word模板出了问题或者Word本身插件出了问题。解决的办法有两个,可以试试看。1、删除默认模板文件首先找到默认模板文件,对于Word 2003来说默认模板文件名为normal.dot,而对于word 2007和word 2010名字则是Normal.dotm。路径都差不多,WinXP下通常位于C:\Documents and Settings\用户名\Application Data\Microso. 阅读全文

c++模板类/模板函数的声明与定义应该放在头文件里

2012-06-29 16:52 by youxin, 3726 阅读, 0 推荐, 收藏,
摘要:如果函数模板按照普通的函数声明放在头文件的,定义放在。cpp文件,会出现错误:模板函数声明、定义、引用有什么要注意的问题么?? -- mylib.h -- template <class T> T max_v(T v1, T v2); -- mylib.cpp -- #include "mylib.h " template <class T> T max_v(T v1, T v2) { return (v1 > v2 ? v1 : v2); } -- ... 阅读全文

c++ STL unique

2012-06-29 13:46 by youxin, 806 阅读, 1 推荐, 收藏,
摘要:unique用来去掉重复的元素。函数原型如下:template ForwardIterator unique ( ForwardIterator first, ForwardIterator last );template ForwardIterator unique ( ForwardI... 阅读全文

转:正确区分不同的查找算法count,find,binary_search,lower_bound,upper_bound,equal_range

2012-06-29 02:00 by youxin, 1087 阅读, 0 推荐, 收藏,
摘要:首先可供查找的算法大致有count,find,binary_search,lower_bound,upper_bound,equal_range。带有判别式的如count_if,find_if或者binary_search的派别式版本,其用法大致相同,不影响选择,所以不作考虑。注意这些查找算法需要序列式容器,或者数组。关联容器有相应的同名成员函数except binary_search。首先,选择查找算法时,区间是否排序是一个至关重要的因素。可以按是否需要排序区间分为两组:A. count,findB. binary_search,lower_bound,upper_bound,equal_r 阅读全文

c++ 无法链接的外部变量

2012-06-29 01:34 by youxin, 393 阅读, 0 推荐, 收藏,
摘要:这是一个很头疼的问题,一般是由于只有声明没有定义,编译时只查找声明,没有报错,链接就报错了。若在头文件了声明:bool compName(const Student &,const Student &);。cpp文件里定义如下:bool compName(const Student &p1,const Student &p2){ return p1.name<p2.name;}链接时会报错,无法链接的外部变量compName。上面的声明中类型为const ,定义却没有,或者反过来,只要声明和定义不一致都会出现错误。在c++中,出现const要谨慎。慎用co 阅读全文

c++ STL equal_range lower_bound upper_bound

2012-06-28 20:13 by youxin, 1058 阅读, 0 推荐, 收藏,
摘要:用来得到容器中等于一个值的子序列。template <class ForwardIterator, class T> pair<ForwardIterator,ForwardIterator> equal_range ( ForwardIterator first, ForwardIterator last, const T& value );template <class ForwardIterator, class T, class Compare> pair<ForwardIterator,ForwardIterator> equa 阅读全文

c/c++ 调用dos 命令

2012-06-28 17:44 by youxin, 766 阅读, 0 推荐, 收藏,
摘要:需要用到这个函数:int system ( const char * command ); (头文件为cstdlib)Execute system commandInvokes the command processor to execute a command. Once the command execution has terminated, the processor gives the control back to the program, returning anintvalue, whose interpretation is system-dependent.The fun. 阅读全文

C++基类与派生类的转换

2012-06-28 16:42 by youxin, 462 阅读, 0 推荐, 收藏,
摘要:只有公用派生类才是基类真正的子类型,它完整地继承了基类的功能。基类与派生类对象之间有赋值兼容关系,由于派生类中包含从基类继承的成员,因此可以将派生类的值赋给基类对象,在用到基类对象的时候可以用其子类对象代替。具体表现在以下几个方面:1派生类对象可以向基类对象赋值。 可以用子类(即公用派生类)对象对其基类对象赋值。如 A a1; //定义基类A对象a1 B b1; //定义类A的公用派生类B的对象b1 a1=b1; //用派生类B对象b1对基类对象a1赋值在赋值时舍弃派生类自己的成员。实际上,所谓赋值只是对数据成员赋值,对成员函数不存在赋值问题。请注意: 赋值后不能企图通过对象a1去... 阅读全文

c++ max_elment和min_element

2012-06-28 00:48 by youxin, 742 阅读, 0 推荐, 收藏,
摘要:max_element和min_element用来求一个范围内的最大值和最小值template <class ForwardIterator> ForwardIterator max_element ( ForwardIterator first, ForwardIterator last );template <class ForwardIterator, class Compare> ForwardIterator max_element ( ForwardIterator first, ForwardIterator last, ... 阅读全文

转:c++ 基类转换为派生类

2012-06-27 21:27 by youxin, 725 阅读, 0 推荐, 收藏,
摘要:基类类型的引用或指针既可以引用基类对象,也可以引用派生类对象,但编译器只把它当做基类类型对象。#include <iostream>using namespace std;class base{public: base():cat(0){} void print() { cout << "cat" << cat << endl; }private: int cat;};class derive:public base{public: derive():base(),dog(1){} //这里base()可以不用写,默认调用无参 阅读全文
上一页 1 ··· 227 228 229 230 231 232 233 234 235 ··· 269 下一页