c++基础库

baseclass类

2017-11-15  本文已影响0人  老练子丶2017

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

.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

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

上一篇 下一篇

猜你喜欢

热点阅读