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È´¿ÉÒÔÇø·Ö...
Ïà¹ØÎĵµ£º
×î½üÒª¸Äдһ¸öºËÐļÓÃÜÈÏÖ¤À࣬´ÓC#¸Äд³ÉJava¡£
·¢ÏÖÔÚµ÷ÊÔʱ£¬¼ÓÃܵÄÊý¾ÝÎÞÂÛÈçºÎÒ²¶Ô²»ÉÏ¡£
¾¹ý¸ú×Ù£¬·¢ÏÖÎÊÌâ³öÔÚC#ºÍJava byteÀàÐ͵ÄÇø±ðÉÏ£ºÔÚC#Àï byteÀàÐÍÊÇÎÞ·ûºÅµÄ£¬¶øJavaÀïÊÇÓзûºÅµÄ£¬ËùÒÔC#ÀïµÄ129µ½JavaÀï¾Í³ÉÁ˸ºÊý¡£
·¢ÏÖÁËÎÊÌ⣬½â¾ö¾Í±È½ÏÈÝÒ×ÁË£¬Õë¶ÔJavaµÄbyte£¬²ÉÓÃIntÀ´½øÐд洢¡£
ͨ¹ýÈçÏ´ú ......
xmlÎļþÈçÏ ÅäÖù¦ÄÜ¿ª¹Ø
<Configurations>
<Samples>true</Samples>
<Excepts>true</Excepts>
<CheckFace>false</CheckFace>
<ThumbNail>false</ThumbNail>
&nbs ......
Ô½½çÊÇ×îÄѲéµÄ£¬×¢Òâmemcpy strcpy,strncpyÕâЩº¯ÊýʹÓÃÇ°Ò»¶¨Òª¼ì²é±ß½ç
¡¡ÌرðÊÇÄãÌṩº¯Êý¸ø±ðÈËÓÃʱ£¬ÄãµÄº¯ÊýÖÐÓõ½ÁËÕâЩ¶«Î÷£¬Ò»¶¨Òª¼ì²é±ðÈË´«¸øÄãµÄÖ¸ÕëµÄ
¡¡±ß½ç
2¡¢±äÁ¿³õʼ»¯
¡¡ÕâÖÖÎÊÌâÒªÑø³ÉºÃÏ°¹ß£¬·ñÔò³öÀ´Å¼È»ÐÔÎÊÌ⣬·Ç³£ÄѲé
3¡¢¶àÏß³ÌÖ¸Õë¹ÜÀí
¡¡ÔÚ¶àÏ̻߳·¾³ÏÂʹÓÃÖ¸Õëʱ£¬×îºÃ²ÉÓÃÒýÓü ......
---------------------------------------------------
Ãû µÈ¼ÛÖµ º¬ Òå
BLACK 0 ºÚ
BLUE 1 ......
ÏßÐÍ
-----------------------------------------------------
Ãû ³Æ È¡ Öµ º¬ Òå
-----------------------------------------------------
SOLID_LINE 0 & ......