65,187
社区成员




#include<stdio.h>
#include<string.h>
class Person
{
public:
Person(char *name, int age);
~Person();
public:
char * GetName() const {return (char*)&this->m_name;}
int GetAge() const {return this->m_age;}
virtual void Say();
protected:
char m_name[20];
int m_age;
};
Person::Person(char *name, int age)
{
strcpy(this->m_name, name);
this->m_age = age;
}
Person::~Person()
{
//
}
void Person::Say()
{
printf("My name is %s, I'm %d this year.\n", this->m_name, this->m_age);
}
//////////////////////////////////////////////////////////////////////////
class Student : public Person
{
public:
Student(char *name, int age, int id);
~Student();
public:
virtual void Say();
protected:
int m_id;
};
Student::Student(char *name, int age, int id)
: Person(name, age)
{
this->m_id = id;
}
Student::~Student()
{
}
void Student::Say()
{
printf("I am a student by the name of %s, I'm %d, my id is %d.\n",
this->m_name, this->m_age, this->m_id);
}
int main()
{
Person pa("pa", 12);
Student s("st", 20, 2008);
Person *ps = &s;
pa.Say();
s.Say();
ps->Say();
printf("&pa:%0x\n", &pa);
printf(" &s:%0x\n", &s);
printf(" ps:%0x\n", ps);
printf("pa.say:%0x\n", pa.Say);
printf(" s.say:%0x\n", s.Say);
printf("ps.say:%0x\n", ps->Say);
return 0;
}
0040EE8D push offset @ILT+35(`vcall') (00401028)
0040EE92 push offset string "pa.say:%0x\n" (004260a0)
0040EE97 call printf (004014c0)
0040EE9C add esp,8
0040EE9F push offset @ILT+35(`vcall') (00401028)
0040EEA4 push offset string " s.say:%0x\n" (00426094)
0040EEA9 call printf (004014c0)
0040EEAE add esp,8
0040EEB1 push offset @ILT+35(`vcall') (00401028)
0040EEB6 push offset string "ps.say:%0x\n" (00425084)
0040EEBB call printf (004014c0)
0040EEC0 add esp,8
00401028 E9 83 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC 閮...烫烫烫烫烫烫烫.
0040103C CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC 烫烫烫烫烫烫烫烫烫烫
00401050 55 8B EC 83 EC 44 53 56 57 51 8D 7D BC B9 11 00 00 00 B8 CC U嬱冹DSVWQ峿脊....柑
00401064 CC CC CC F3 AB 59 89 4D FC 8B 45 FC C7 00 1C 50 42 00 8B 4D 烫腆玒塎鼖E..PB.婱
00401078 08 51 8B 55 FC 83 C2 04 52 E8 0A 03 00 00 83 C4 08 8B 45 FC .Q婾鼉..R.....兡.婨.
@ILT+0(??1Person@@QAE@XZ):
00401005 jmp Person::~Person (004010c0)
@ILT+5(?Say@Student@@UAEXXZ):
0040100A jmp Student::Say (00401220)
@ILT+10(??0Student@@QAE@PADHH@Z):
0040100F jmp Student::Student (00401160)
@ILT+15(??1Student@@QAE@XZ):
00401014 jmp Student::~Student (004011d0)
@ILT+20(??0Person@@QAE@PADH@Z):
00401019 jmp Person::Person (00401050)
@ILT+25(_main):
0040101E jmp main (0040edd0)
@ILT+30(?Say@Person@@UAEXXZ):
00401023 jmp Person::Say (00401100)
00401028 jmp `vcall' (004010b0)
004010B0 mov eax,dword ptr [ecx]
004010B2 jmp dword ptr [eax]
004010B4 int 3
004010B5 int 3
004010B6 int 3
004010B7 int 3