|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#ifndef MYFUNCTION_H_INCLUDED
#define MYFUNCTION_H_INCLUDED
#endif // MYFUNCTION_H_INCLUDED
#include<stdlib.h>
#include<iostream>
using namespace std;
class Myfunction
{
public:
Myfunction(int ,int );
~Myfunction();
virtual void Sum();
int m_a,m_b;
};
Myfunction::Myfunction(int a,int b)
{
cout<<"Myfunction调用构造函数"<<endl;
m_a = a;
m_b = b;
}
Myfunction::~Myfunction()
{
cout<<"Myfunction调用析构函数"<<endl;
}
Myfunction::void Sum()
{
cout<<m_a + m_b<<endl;
}
#ifndef LITTLEBOY_H_INCLUDED
#define LITTLEBOY_H_INCLUDED
#endif // LITTLEBOY_H_INCLUDED
#include<stdlib.h>
#include<iostream>
#include"Myfunction.h"
using namespace std;
class Littleboy:public Myfunction
{
public:
Littleboy(int a,int b);
~Littleboy();
virtual void Sum();
private:
int m_a,m_b;
};
Littleboy::Littleboy(int a,int b)
{
cout<<"Littleboy的构造函数"<<endl;
m_a = a;
m_b = b;
}
Littleboy::~Littleboy()
{
cout<<"Littleboy的析构函数"<<endl;
}
Littleboy::void Sum()
{
cout<<m_a - m_b<<endl;
}
#include<stdlib.h>
#include<iostream>
#include"Littleboy.h"
using namespace std;
int main()
{
Littleboy p(3,4);
p.Sum();
}
|
|