C/C++ÓëJavaº¯ÊýÖØÔØÇø±ð!
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// º¯ÊýµÄÖØÔØ,ÕâÑùµÄÖØÔØ·½Ê½,ÔÚJavaÖÐÄÜÐÐ,ÔÚC/C++ÖÐÈ´²»ÐÐ
virtual void fn(float x) {
cout << "In SubClass, float x = " << x << endl;
}
};
void test(Base& b) {
int i = 1;
b.fn(i);
float f = 2.0;
b.fn(f);
}
int main() {
Base bc;
SubClass sc;
cout << "Calling test(bc)\n";
test(bc);
cout << "Calling test(sc)\n";
test(sc);
return 0;
}
Calling test(bc)
In Base class, int x = 1
In Base class, int x = 2
Calling test(sc)
In Base class, int x = 1
In Base class, int x = 2
ÔËÐгɹ¦£¨×ܼÆʱ¼ä£º 312ºÁÃ룩
×¢Òâ,¶¼Êǵ÷Óõĸ¸ÀàÖеĺ¯Êý.
package cn.vicky;
public class MyTest {
public void add(int i) {
System.out.println("in parent");
}
public static void main(String[] args) {
MyTest2 m2 = new MyTest2();
m2.add(1);
m2.add(1.1);
}
}
class MyTest2 extends MyTest {
public void add(double i) {
System.out.println("in child");
}
}
in parent
in child
JavaÈ´¿ÉÒÔÇø·Ö...
Ïà¹ØÎĵµ£º
ÎÒÃÇΪʲôҪȥÃæÊÔ ? ÃæÊÔµÄÄ¿µÄÊÇʲô ?
ÃæÊÔÒª½â¾öÄļ¸¸öÎÊÌâ ?
Ò»¡¢ÃæÊÔµÄÄ¿µÄ
¶þ¡¢ÃæÊÔÇ°µÄ×¼±¸
Èý¡¢ÃæÊÔ³£¼ûÎÊÌâ½â´ð
A¡¢ÏîÄ¿¾Àí³£¼ûÎÊÌâ
B ......
alloc.h
brk
¡¾¹¦ÄÜ¡¿¸ü¸ÄÊý¾Ý¶Î¿Õ¼äµÄ·ÖÅä
¡¾ÔÐÍ¡¿int brk(void *endds)
¡¾Î»Öá¿alloc.h
¡¾ËµÃ÷¡¿½«³ÌÐòÊý¾Ý¶ÎµÄ¶¥²¿ÉèÖÃΪenddsËùÖ¸ÏòµÄÄÚ´æλÖᣵ÷Óóɹ¦Ö®ºó£¬·µ»Ø0¡£Èç¹ûµ÷ÓÃʧ°ÜÔò·µ»Ø-1£¬Í¬Ê±ÉèÖÃerrno¡£
¡¾²Î¼û¡¿coreleft
calloc
¡¾¹¦ÄÜ¡¿·ÖÅäÄÚ´æ¡£
¡¾ÔÐÍ¡¿void *calloc(size_t nelem,size_t elsize) ......
Ò»¡¢Ò»¸ö¾¹ý±àÒëµÄC/C++µÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·Ö³ÉÒÔϼ¸¸ö²¿·Ö£º
¡¡¡¡1¡¢Õ»Çø£¨stack£©£ºÓɱàÒëÆ÷×Ô¶¯·ÖÅäºÍÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ¡¢¾Ö²¿±äÁ¿µÄÖµµÈ£¬ÉõÖÁº¯ÊýµÄµ÷Óùý³Ì¶¼ÊÇÓÃÕ»À´Íê³É¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
¡¡¡¡2¡¢¶ÑÇø£¨heap£© £ºÒ»°ãÓɳÌÐòÔ±ÊÖ¶¯ÉêÇëÒÔ¼°ÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ......
1¡¢Ñ¡ÔñºÏÊʵÄËã·¨ºÍÊý¾Ý½á¹¹
Ñ¡ÔñÒ»ÖÖºÏÊʵÄÊý¾Ý½á¹¹ºÜÖØÒª£¬Èç¹ûÔÚÒ»¶ÑËæ»ú´æ·ÅµÄÊýÖÐʹÓÃÁË´óÁ¿µÄ²åÈëºÍɾ³ýÖ¸ÁÄÇʹÓÃÁ´±íÒª¿ìµÃ¶à¡£Êý×éÓëÖ¸ÕëÓï¾ä¾ßÓÐÊ®·ÖÃÜÇеĹØϵ£¬Ò»°ãÀ´Ëµ£¬Ö¸Õë±È½ÏÁé»î¼ò½à£¬¶øÊý×éÔò±È½ÏÖ±¹Û£¬ÈÝÒ×Àí½â¡£¶ÔÓڴ󲿷ֵıàÒëÆ÷£¬Ê¹ÓÃÖ¸Õë±ÈʹÓÃÊý×éÉú³ÉµÄ´úÂë¸ü¶Ì£¬Ö´ÐÐЧÂʸü¸ß¡£
ÔÚÐí¶àÖÖÇ ......