Exemplo n.º 1
0
int main(int argc, const char * argv[]) {
    Man *m = new Man();
    delete m;
    
    m = new Man(20);
    printf("Man->age = %d\n",m->getAge());
    m->setAge(30);
    printf("Man->age = %d\n",m->getAge());
    
    
    delete m;
    
    return 0;
}
Exemplo n.º 2
0
int main()
{
    Man *m = new Man(1, "Man:WuWenhao");
    //执行当前类的函数
    //若派生类与基类有相同的函数,则运行派生类的函数,否则运行基类的函数
    m->sayHello();
    //执行父级函数
    m->People::sayHello();

    People *p1 = new Man();
    p1->sayHello();

    m->Eat();
    p1->Eat();
    p1->Sleep();


    int age = m->getAge();
    int sex = m->getSex();
    char *name = m->getName();

    delete m;
    delete p1;
    return 0;
}
Exemplo n.º 3
0
int main(int argc, const char * argv[])
{
    Man *m = new Man(20);
    printf("age %d\n",m->getAge());
    delete m;
    return 0;
}
Exemplo n.º 4
0
int main() {
    Man *m = new Man();
    m -> sayHello();

    printf("man age is %d\n", m->getAge());

    return 0;
}
Exemplo n.º 5
0
int main(int argc, const char * argv[]) {
    
    Man *m = new Man(20);
    
    
    printf("age:%d\n",m->getAge());
    
    
    
    std::cout << "Hello, World!\n";
    return 0;
}