c++中的单态模式。(就是不知道为什么用typedef)

来源:互联网 发布:java decimalformat 编辑:程序博客网 时间:2024/06/05 10:18
// Array.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <iostream.h>class A{       typedef A* PA;private:   static  const PA pa;       A(){}public:   static const PA GetA(){     return pa;   }   void hello() const {         cout<<"Hello!"<<endl;   }       };const A::PA A::pa=new A();//const static  A  pa;int main(int argc, char* argv[]){    A* pa=A::GetA();pa->hello();}

 

阅读全文
0 0