给几道c++的改错题做做

来源:百度知道 编辑:UC知道 时间:2024/05/12 06:37:20

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

#define _class_name(a, b, c) string a##b(){ return string(#c); }

template <typename Der>
class Base
{
public:
Der & Ref(void){ return static_cast<Der&>(*this); }
Der * operator ->(void){ return static_cast<Der*>(this); }
static Der & CreateObjectRef(){ Der *p = new Der; return *p; }
static void DeleteObjectRef(Base<Der> &p){ delete &p; }
const Der* ClassID() { return (static_cast<Der*>(this)); }
_class_name(Class, Name, Der)
};

class Derive : public Base<Derive>
{
public:
void Show(){ cout<<"hi derive"<<endl; }
};
template<typename T>
void Print(Base<T> &b)
{
b.Ref().Show();
b->Show();
}
class Three
{
public:
template<