Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

nisse

By: a guest on Nov 9th, 2007  |  syntax: C++  |  size: 0.90 KB  |  views: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "gregorian.h"
  2. #include "julian.h"
  3. #include <time.h>
  4. #include <assert.h>
  5. using namespace lab2;
  6. using namespace std;
  7.  
  8. template <class T> struct bar{
  9.   bar<T>(){
  10.     dp = new T;
  11.   }
  12.   bar<T>(int a){
  13.     dp=new T(a);
  14.   }
  15.  
  16.   bar<T> & operator=(const bar<T> &ref) {
  17.     *dp=*(ref.dp);
  18.   }
  19.  
  20.   void print(){
  21.     cout << *dp<<endl;
  22.   };
  23.   Date * dp;
  24. };
  25.  
  26.  
  27. int main(int argc, char **argv)
  28. {
  29.   time_t a = time(NULL);
  30.   set_k_time(a);
  31.  
  32.   bar<Julian> j;
  33.   bar<Gregorian> g;
  34.   bar<Gregorian> g2(20);
  35.  
  36.   cout << "bar<Julian> j:";
  37.   j.print();
  38.   cout <<"bar<Gregorian> g:";
  39.   g.print();
  40.   cout <<"bar<Gregorian> g2:";
  41.   g2.print();
  42.  
  43.   cout << "** g=g2 **" <<endl;
  44.   g=g2;
  45.   cout <<"g:";
  46.   g.print();
  47.   cout <<"g2;";
  48.   g2.print();
  49.  
  50.   cout << "** j=g **"<<endl;
  51.   j=const_cast< bar<Julian> *>g;
  52.   cout << "b";
  53.   //b.print();
  54.   cout <<"f";
  55.   //f.print();
  56.  
  57.   return 0;
  58. }