·¢ÏÖÒ»¸öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½
¸Õ¸Õ¿´µ½Ò»ÆªÎÄÕÂÌá³öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½£¬»ù±¾Òâ˼ÈçÏ£º
Çë¿´C++´úÂ룺
class Base
{
public:
Base()
{
init();
}
virtual ~Base() {}
protected:
int value;
virtual void init()
{
value = 100;
}
};
class Derived : public Base
{
public:
Derived()
{
init();
}
protected:
void init()
{
cout << "value = " << value << endl;
// ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷
}
};
int main(int argc, char* argv[])
{
Base* pb;
pb = new Derived();
delete pb;
return 0;
}
Ö´Ðнá¹ûÊÇ
value = 100
ÔÙ¿´java´úÂ룺
class Base
{
public Base()
{
init();
}
protected int value;
protected void init()
{
value = 100;
}
}
class Derived extends Base
{
public Derived()
{
init();
}
protected void init()
{
System.out.println("value = " + value);
// ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷
}
}
public class Test
{
public static void main(String[] args)
{
Base base = new Derived();
}
}
Ö´Ðнá¹ûÊÇ
value = 0
value = 0
ÔÚjavaÖÐ×ÓÀàµÄinit·½·¨ÖØÐ´Á˸¸ÀàµÄinit·½·¨£¬µ¼Ö²»ÄÜÕýÈ·Íê³É³õʼ»¯¡£¿´µ½ÕâÀïÎÒ˼¿¼ÁËһϣ¬ÓÉÓÚ×ÓÀàÖØÐ´Á˸¸ÀàµÄͬÃûº¯Êý£¬²Åµ¼Ö±¾Ó¦¸ÃÖ´Ðеĺ¯ÊýûÓÐÖ´ÐУ¬Èç¹ûÐ޸ĸ¸ÀàµÄ³õʼ»¯º¯Êý»òÕß×ÓÀàµÄ³õʼ»¯º¯Êý£¬Ê¹×ÓÀ಻»á·¢ÉúÖØÐ´£¬ÊDz»ÊǾͲ»»á·¢ÉúÉÏÃæµÄÇé¿ö£¿»òÐí¼´Ê¹ÊÇ×ÓÀàÓ븸À࣬µ±Éæ¼°µ½¸÷×Եijõʼ»¯µÄµØ·½Ê±¾Í²»Ó¦¸ÃʹÓöà̬ÐÔ¡£
Ïà¹ØÎĵµ£º
ÍøÉÏÒ»µÀ½ðɽµÄÃæÊÔÌ⣺
http://topic.csdn.net/u/20100524/14/0eff992a-2849-4db6-bdaa-d4a200e79b7c.html
Çë·Ö±ðÓÃC++µÄÃæÏò¶ÔÏóºÍ·ºÐÍ»úÖÆ£¬±àдʵÏÖTemplate MethodģʽµÄʾÀý´úÂ룬²¢±È½ÏÁ½ÖÖ·½Ê½¸÷×ÔµÄÓÅȱµã¡£
ÓÃÐ麯ÊýʵÏÖTemplate MethodµÄ·½Ê½¾Í²»¶à˵ÁË¡£Ó÷ºÐ͵ķ½Ê½ÊµÏÖ¶à̬ÔÚATLÀïÃæÓдóÁ¿µÄÓõ½£¡
·ºÐ͵ ......
Ò»¡¢ÔËËã·û
ËãÊõÔËËã·û£º+£¬-£¬*£¬/£¬%£¬++£¬--
¹ØÏµÔËËã·û£º>£¬<£¬>=£¬<=£¬==£¬!=
²¼¶ûÂß¼ÔËËã·û£º!£¬&£¬^£¬|£¬&&£¬||
λÔËËã·û£º&£¬|£¬^£¬>>£¬<<£¬>>>
¸³ÖµÔËËã·û£º=
À©Õ¹¸³ÖµÔËËã·û£º+=£¬-=£¬*=£¬/=
×Ö·û´®Á´½ÓÔËËã·û£º+
Á½ÊýÏà³ý£¬ÄÇôÈç¹û ......
C/C++
Í·ÎļþÒ»ÀÀ
//////////////////////////////////////////////////////////////////////////
C
Í·Îļþ
(C89,C95)
(C++98,C++03Ò²°üº¬)
include <assert.h>¡¡¡¡¡¡¡¡//Õï¶Ï¿â
include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àíº¯Êý¿â
include <errno.h>¡¡¡¡¡¡¡¡ //´íÎó¶¨Òå
include <float.h& ......
JavaÖеÄstartsWithºÍendsWith·½·¨£¬ÔÚfilterµÄ¹¦ÄÜʵÏÖÖкܷ½±ã£¬PHP¿ÉÒÔÓÃstrncmp()
ʵÏÖstartsWith£¬µ«ÊÇÎÞ·¨ÊµÏÖendsWith£¬ÓÐЩÈË»áÓÃÕýÔòÀ´ÊµÏÖ£¬µ«´ó¶àÊýÈ˶¼²»Ï²»¶ÕýÔò±í´ïʽµÄ²Ù×÷¡£
ÕâÀïÎÒͨ¹ýÒ»¸ö½Ðsubstr_compareµÄ·½·¨ÊµÏÖ(ͬʱËûÒ²ÄÜʵÏÖsta ......
JavaÖÐDateÀàÖеÄһЩÈÕÆÚ¸ñʽ»°·½·¨¶¼ÒѹýÆÚ£¬ËùÒÔ²»ÍƼöʹÓá£
Ò»°ã¸ñʽ»¯Ê±£¬³£Óõ½ÕâÁ½¸öÀࣺCalendar
ºÍSimpleDateFormat
£¬Ê¹Ó÷½·¨ÈçÏ£º
1.CalendarÀà
CalendarÀàÊÇabstractµÄ£¬ËùÒÔʵÀý»¯·½Ê½µÃÓþ²Ì¬·½·¨£º
Calendar c = Calendar.getInstance();£¬
´ËʱµÄÉú³ÉµÄʵÀýÒÀ¾ÝµÄÊǵ±Ç°ÏµÍ³Ê±¼ä£»c.setTime(java ......