自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 资源 (8)
  • 收藏
  • 关注

原创 在Maven2的项目中,设置编译时用的JDK

在使用Maven2构建项目的时候,发现编译时用的是JDK1.4,使得范型不能使用,其实只需要在pom.xml中添加如下配置就可以解决问题                                         org.apache.maven.plugins                maven-compiler-plugin    

2009-08-29 14:24:00 2013

原创 hibernate使用list进行多对多关联时中间表的主键策略

在hibernate中,使用list的进行多对多关系映射时,中间表的主键并不是由两个外键作为联合主键的,而是由一个外键和一个索引列作为联合主键。那么该hibernate会使用那个外键来作为联合主键呢?这会根据是否双向多对多,是否设置inverse属性和inverse属性设在哪一方而发生改变。1.双向多对多考虑以下hiberante映射ManyDoo.hbml.xml:

2009-08-04 15:44:00 6221

原创 Oracle外键约束信息的查询

select    a.table_name 从表, a.column_name 外键列,  b.table_name 主表, b.column_name 被引用列from     (    select        uc.table_name, ucc.column_name, uc.r_constraint_name    from        user_con

2009-06-24 12:55:00 1766

原创 为什么Synchronized block要使用this作同步

为什么Synchronized block要使用this作同步学Java并发编程时遇到过一个问题:为什么凡是涉及到Synchronized block的代码,总是使用synchronized(this)这样的代码。一开始很疑惑不解,既然Synchronized block可以通过获得对象的锁来使得多个线程对同一对象的访问同步,那么Synchronized block可以使用任何对象(比如成员变量)

2009-04-04 23:38:00 2419

原创 在运行时开启断言的方法

ClassLoader.setDefaultAssertionStatus(true);ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);

2009-03-29 20:42:00 689

转载 ECLIPSE找不到插件的解决方法

原文地址:http://blog.113e.com/327615.shtml有时启动eclipse未加载插件,解决方法很多,总结一下:删除整个目录/eclipse/configuration/org.eclipse.update/,重启eclipse在启动eclipse时带上 -clean参数          如:d:/eclipse/eclipse.exe -clean如果

2009-03-13 21:15:00 3635 2

原创 java中获得文件流的两种方法

InputStream in = new FileInputStream(xmlPath); // 相对于项目所在路径InputStream in = getClass().getResourceAsStream(xmlPath); // 相对于当前类.java所在路径

2009-03-13 21:14:00 1266

原创 确保Runtime.getRuntime().exec()执行结束再执行下一步

Runtime.getRuntime().exec()是一个很有用的函数,可以调用操作系统的shell指令。但是这个函数有一个问题,当它把传给它的控制台命令丢给shell执行后,它就立即返回了。 这个问题看起来不大,但是如果我们用shell指令复制一个A文件到B文件,然后在下一语句中对B文件进行操作,那么问题就来了。因为shell指令很可能还没有执行完(而exec( )函数却已经返回了

2009-02-20 20:22:00 10891 2

原创 关于synchronized关键字的那些事儿

 一、对象级别的同步1.类A有一个synchronized F(),一旦某Thread#1调用A类对象a.F(),则在F()返回前,Thread#2是不能够调用a.F()的。2.若类A中还有一个synchronized G(),那么在a.F()返回前,Thread#2也是不能够调用G()的。以上两种情况,Thread#2在a.F()返回前,都会进入blocking(阻塞)状态。注意:1.如果类

2009-02-16 21:51:00 584

原创 Atomicity(原子性),visibility(可被观察性),volatility(挥发性)

一、Atomicity(原子性)定义:atomic操作是指一个不会被thread scheduler打断的操作箴言:1.除非你是多线程【专家】,否则不要使用atomicity来代替synchronization2.有时候,即使一些操作看上去是atomicity,但实际上它可能并不是3.任何对去掉synchronization的尝试,通常是不成熟优化的信号,并带来许多麻烦应用:1.atomicity

2009-02-16 21:47:00 1112

原创 如何使得一个JComponent组件不论是否获得焦点,都可以响应键盘事件

这个问题来自于一个课程作业,作业要求不论什么情况下按alt-h都可以使得JTabbedPane中的一个Pane变成选中。我试过很多方法,比如为JTabbedPane添加一个KeyListener,这个方法的确成功了,但是如果其他Pane中的组件获得了焦点(比如JTextField),那么按alt-h就失效了。还想过给JFrame添加KeyListener,结果压根JFrame收不到任何键盘

2009-02-11 22:50:00 1477 1

原创 12只球,有1个重量不同,称3次找出坏球

 图比较大,点击这里下载:http://p.blog.csdn.net/images/p_blog_csdn_net/matrixdwy/EntryImages/20090118/12只球1个不同.jpg

2009-01-18 13:59:00 1179

原创 将屏幕坐标转换成客户区坐标

GetCursorPos(&posMouse);        //这个posMouse是桌面坐标 ScreenToClient(&posMouse);      //将桌面坐标转换成客户区坐标

2008-12-17 14:23:00 1473

原创 如何使得弹出式菜单的某一项变灰

 CMenu popMenu; popMenu.LoadMenu(IDR_MENUS); CPoint posMouse; GetCursorPos(&posMouse); // 需要在调用弹出式菜单之前就对它的菜单项进行开关选择  popMenu.GetSubMenu(1) ->EnableMenuItem(...); popMenu.GetSubMenu(1

2008-12-16 23:27:00 979

原创 根据层次遍历和中序遍历的结果还原一颗二叉树

此文件描述了根据层次遍历,中序遍历的结果来还原二叉树的算法我们先分别给出一个层次遍历,和一个中序遍历的结果字符串 层次  A B C D E F G 中序  D B A F E G C其对应的二叉树是:       A     /  /     B  C     /  /     D  E       / /       F G接下来详细讲解如果还原这棵二叉树的步骤,我用LEV代表层次遍历MID代

2008-10-20 20:18:00 5794 4

原创 根据后序-中序遍历结果 来还原一颗二叉树

后序-中序-二叉树还原对于这样一个二叉树           A       /       /       B       C     /   /   /   /     D   E   F   G    / / / / / / / /    H I J K M N O P后序遍历的结果是:HIDJKEBMNFOPGCA,我们称之为POST中序遍历的结

2008-10-19 16:22:00 3490 1

原创 size_t 的陷阱

size_t是无符号整形,平常用的时候没有觉得有什么问题,但是今天的一个程序怎么弄就是不对,反复检查逻辑错误并没有发现有什么错误,而且程序本身逻辑并不复杂,搞得我头很大。后来经过一番探索,终于发现其错误发生在size_t上。废话不多说,直接给代码。 #include  using namespace std;int main() {    size_t t = 1;

2008-10-19 15:51:00 684

原创 根据前序遍历-中序遍历结果 来还原一颗二叉树

前序-中序-二叉树还原对于这样一个二叉树         A     /       /     B       C   /   /   /   /   D   E   F   G  / / / / / / / /  H I J K M N O P 前序遍历的结果是:ABDHIEJKCFMNGOP,我们称之为PRE中序遍历的结果是:HDIBJEKAMFNCOGP,我们称之为MID还原的方法

2008-10-19 12:34:00 2872

原创 SetWindowOrg和SetViewportOrg

 SetWindowOrg和SetViewportOrg这两个函数比较难搞懂,经过本人的google和实践终于弄明白了这两个函数的本质区别。1.SetWindowOrg    是把设备坐标的原点移动到逻辑坐标的(X, Y)处2.SetViewportOrg  是把逻辑坐标的原点移动到设备坐标的(X, Y)处注意设备坐标和逻辑坐标的区别:1.设备坐标的X, Y轴方向是固定的,单位也是

2008-09-11 15:18:00 1404

原创 如何在DEV C++中编译ZThread。

在Thinking in C++ 第二卷中有一章节专门讲述并发,其中的例子需要ZThread,本文就介绍如何在DEV C++中编译ZThread库准备工作1.首先,你需要下载 ZThread-2.3.2。2.然后解压缩,这是一个tar文件,你可以用GNUWin32下的TAR解压缩,顺便一提,许多开源项目的压缩包都用到TAR和GZIP压缩格式,为了以后方便,你也可以下载一个GZIP:

2008-08-09 08:24:00 4118

原创 前一段时间很红的金山3题

1、编程计算从 1 到 2008080808 之间的整数有多少个含有数字7。 2、结构RECT可以表示一个平面上的矩形区域: struct RECT {   int left, right, top, bottom; }; 编程计算两个矩形区域A和B构成的区域总面积。 3、将给定的字符串以词为单位倒序,同时给定一个子串,若字符串中有部分内容与子串相同则该部分不倒序。 例:给定字符串“The

2008-06-23 23:10:00 919

原创 C++编程思想 第二卷 勘误

注:这是我本人在看C++编程思想 第二卷:实用编程技术(刁成嘉译)时发现的翻译问题。特此列一表,供各位参考及讨论 。本人收集的翻译不妥之处大部分为那些狗屁不通之句,影响读者理解之句以及误人子弟之句。关于名词翻译的修改较少,希望能够给各位软件初学者以一定帮助。若本人勘误有错,欢迎指正。  勘误连接 第一章 异常处理

2008-06-17 21:34:00 2673 6

原创 TICPP CHAPTER 11 EX 27 & EX28

/*27. Start with FunctionTable.cpp from Chapter 3. Create aclass that contains a vector of pointers to functions, withadd( ) and remove( ) member functions to add andremove pointers to funct

2008-05-23 22:50:00 674

原创 二进制数字的乘法

这两天一直在自学离散数学,有一道题目,花了我3个小时终于做出来了。特拿出来和大家交流//做一个二进制乘法的程序,输入b(n),b(n-1),...,b(0),b(m),b(m-1),...,b(0)//输出c/*二进制的乘法表只有两种1×1=10,1×0=0,0×0=0其中1×1=10是要进位的利用和十进制相似的乘法原理,做出二进制的乘法,看例子    111×      11---

2008-05-22 17:48:00 12774

原创 交换两数,不使用第三变量,且考虑溢出问题

乍看到这个问题觉得挺简单,但是看到需要考虑溢出就不知从何下手后来看到一解法,觉得很有趣:void swap(int &x, int &y){    x = x ^ y;    y = x ^ y;    x = x ^ y;}一开始觉得奇怪,为什么会这样,后来随便拿了两个数字验证了一下,结果果然是这样x:    000110101y:    011010111x=x^y

2008-05-19 23:12:00 813

原创 关于指针引用

 如果修改指针的指向,而非指针所指向的内存空间的内容?先看看下面这段代码void f1(int* ip) {    ip = new int(10);}如果传入一个int* 指针,比如这样int* p;f1(p);实际上执行的是一个pass-by-value(传值)操作,p的指向没有发生改变。解决这个问题有2法:用指针的指针作为参数(a po

2008-05-18 15:31:00 631

原创 CHAPTER 10:EX 19

/*19. Modify FriendInjection.cpp to add a definition for thefriend function and to call the function inside main( ).*/#includeiostream>using namespace std;namespace Me {    class Us 

2008-05-18 00:23:00 393

原创 CHAPTER 10:EX 24

#ifndef BOB_H#define BOB_Hnamespace bob{  class Widget { /* ... */ };  class Poppit { /* ... */ };  // ...}#endif    //BOB_H/**//*24. Extract the namespace declarations inBobsSuperDuperLibrary

2008-05-18 00:22:00 460

原创 CHAPTER 10:EX 34

#ifndef MIRROR_H#define MIRROR_Hclass Mirror ...{    Mirror *next;    bool flag;public:    Mirror():flag(true),next(0)...{}    Mirror(Mirror *p) ...{ next = p; flag = false;}    bool test() ...{    

2008-05-18 00:18:00 466

原创 CHAPTER 10:EX 33

#ifndef MIRROR_H#define MIRROR_Hclass Mirror {    Mirror *next;    bool flag;public:    Mirror():flag(true),next(0){}    Mirror(Mirror *p) { next = p; flag = false;}    bool test() {        if (next

2008-05-18 00:16:00 434

原创 CHAPTER 10:EX 02

/*2. Create a function that returns the next value in aFibonacci sequence every time you call it. Add anargument that is a bool with a default value of false suchthat when you give the argument with

2008-05-18 00:13:00 516 2

原创 CHAPTER 07:EX 01

/**//*1.Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name 

2008-05-18 00:07:00 438

原创 CHAPTER 05:EX 05

/*5. Create three classes. The first class contains private data,and grants friendship to the entire second class and to amember function of the third class. In main( ),demonstrate that all of these

2008-05-18 00:03:00 561

原创 CHAPTER 05:EX 04

/*4. Write two classes, each of which has a member functionthat takes a pointer to an object of the other class. Createinstances of both objects in main( ) and call theaforementioned member function

2008-05-18 00:02:00 596

原创 CHAPTER 04:EX 25

25. Repeat Exercise 24, but put the functions inside a structinstead of using “raw” structs and functions.#ifndef SOLUTION25_H#define SOLUTION25_Hstruct Link {    int count;    Link* next;    vo

2008-05-18 00:00:00 487

原创 CHAPTER 04:EX 24

24. Create a struct that holds an int and a pointer to anotherinstance of the same struct. Write a function that takesthe address of one of these structs and an int indicatingthe length of the list yo

2008-05-17 23:58:00 653

原创 CHAPTER 04:EX 18

/*18. Write a function that takes a char* argument. Using new,dynamically allocate an array of char that is the size ofthe char array that’s passed to the function. Using arrayindexing, copy the cha

2008-05-17 23:53:00 580

原创 CHAPTER 04:EX 07

//7. Make a Stash that holds doubles. Fill it with 25 double//values, then print them out to the console.#ifndef SOLUTION07_H#define SOLUTION07_Hstruct Stash {    int quantity;    int index;    doub

2008-05-17 23:48:00 744

原创 CHAPTER 03:EX 33

/*33. Declare a pointer to a function taking an int argumentand returning a pointer to a function that takes a charargument and returns a float.*/#includeiostream>using namespace std;void main () { 

2008-05-17 23:40:00 422

原创 CHAPTER 03:EX 27

/27. Create a const array of double and a volatile array of//double. Index through each array and use const_cast to//cast each element to non-const and non-volatile,//respectively, and assign a valu

2008-05-17 23:35:00 413

Thinking in C++ Vol.2

Thinking in C++ 第二卷:实用编程技术<br>与市面上的中文版对应的英文版本。英文版的特点就是原汁原味,不像中文版那样翻译得面目全非。<br>此版本是我在原版基础上修改的,在关键部分有注释,一些英文单词有解释,并附有少量插图,并修改了少数原版中的讹误。<br>我已看完了全书,总得感觉上还是值得一读,包含了许多主题,不过其内容只是入门,如需深入研究还需阅读专门的书籍。

2008-08-20

STL Document

full discription of the Standard Template Library

2008-07-27

C++ STL Reference Manua

C++ STL Reference Manual<br>初学者的参考手册

2008-07-14

C++ references

c++ references 参考学习好帮手,初学者的学习的好工具

2008-07-14

Modern C++ Design

Modern C++ Design<br>PDF + CHM<br>English version

2008-07-10

Inside the C++ Object Model

Inside the C++ Object Model<br>English Version<br>PDF format

2008-07-10

SQL Server 2005 程序员开发指南

A Developers Guide to SQL Server 2005 PDF版本,共分为两个压缩包。分别在以下地方: http://download.csdn.net/source/368580 http://download.csdn.net/source/368569 还有一个Introduction to SQL,在http://download.csdn.net/source/368556

2008-03-04

SQL server 2005 程序员开发指南

A Developers Guide to SQL Server 2005 PDF版本,共分为两个压缩包。分别在以下地方: http://download.csdn.net/source/368580 http://download.csdn.net/source/368569 还有一个Introduction to SQL,在http://download.csdn.net/source/368556

2008-03-04

空空如也

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

TA关注的人

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