baseclass类

作者: 老练子丶2017 | 来源:发表于2017-11-15 20:13 被阅读0次

先写个不可复制的抽象类,像单例模式的就可以继承这个类

.cpp文件是个继承测试

baseclass.h

#ifndef _BASECLASS_H

#define _BASECLASS_H

#include <stdio.h>

#include <stdlib,h>

#include <iostream>

using namespace std;

class NonCopy

{

protected:

NonCopy() {

}

virtual ~NonCopy() {

}

private:

NonCopy(const NonCopy&) {

}

const NonCopy& operator=(const NonCopy&) {

}

};

#endif // _BASECLASS_H

baseclass.cpp

#include "baseclass.h"

class Test : public NonCopy

{

public:

Test() {

cout << "test" << endl;

}

};

int main()

{

Test test;

return 0;

}

编译:make baseclass

后面有需要添加的基础类再更新

相关文章

网友评论

    本文标题:baseclass类

    本文链接:https://www.haomeiwen.com/subject/huihvxtx.html