Java与C++的多态
没有必要用一堆绕口的形容词来描述什么叫多态,只举出几个关键点。
设:gun为父类,shootgun和pistol为gun的子类。
Java:
class gun {
void shoot() {
System.out.println("gun shoot");
}
}
class shootgun extends gun {
void shoot() {
System.out.println("shootgun shoot");
}
}
class pistol extends gun {
void shoot() {
System.out.println("pistol shoot");
}
}
C++:
class gun
{
void shoot()
{
cout << "gun shoot" << endl;
}
};
class shootgun : gun
{
void shoot()
{
cout << "shootgun shoot" << endl;
}
};
class pistol : gun
{
void shoot()
{
cout << "pistol shoot" << endl;
&n
相关文档:
http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......
先来了解一下链表模式的原理:
首先写一个JavaBean,内容是要添加的元素和该元素的节点。
public class NodeBean implements Serializable
{
private Object data; //元素本身
private NodeBean next; //下一个节点
&n ......
1、创建了一个对象后:
(1)没有在适当的地方释放掉
(2)在应该释放的地方没有做释放操作
例如:下面一段程序:
m_progressDlg = ProgressDialog.show(this, getString(R.string.market),getString(R.string.is_visiting), true);
new Thread() {
public v ......
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
/**
* 求质数和,
* 如:
* sum(1)=2=2
* sum(2)=2+3=5
* sum(3)=2+3+5=10
* sum(4)=2+3+5+7=17
& ......