DblDate.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- // This is the main project file for VC++ application project
- // generated using an Application Wizard.
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- #using <mscorlib.dll>
- #include <tchar.h>
- using namespace System;
- using namespace System::Threading;
- __value struct Dbl
- {
- double hr,min,sec;
- double val;
- public:
- Dbl(double v) {
- val = v;
- DateTime pDate = DateTime::get_Now();
- hr = pDate.get_Hour();
- min = pDate.get_Minute();
- sec = pDate.get_Second();
- }
- double getVal() { return val; }
- void print() {
- Console::Write("val=");
- Console::Write(val);
- Console::Write(" ");
- Console::Write(hr);
- Console::Write(":");
- Console::Write(min);
- Console::Write(":");
- Console::WriteLine(sec);
- }
- // Increment and decrement
- static Dbl& op_Assign(Dbl& lhs, const Dbl& rhs)
- {
- Console::WriteLine("op_Assign");
- lhs.val = rhs.val;
- DateTime pDate = DateTime::get_Now();
- lhs.hr = pDate.get_Hour();
- lhs.min = pDate.get_Minute();
- lhs.sec = pDate.get_Second();
- return lhs;
- }
- };
- // This is the entry point for this application
- int _tmain(void)
- {
- Console::WriteLine(S"Dbl Example");
- Dbl one(10.0);
- Dbl two(20.0);
- Console::Write("Inc: initial one: ");
- one.print();
- System::Threading::Thread::Sleep(5000);
- one = two;
- Console::Write("Inc: assigned one: ");
- one.print();
- return 0;
- }