Person.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"
- #using <mscorlib.dll>
- using namespace System;
- __gc class Person
- {
- String* name;
- int dd, mm, yyyy;
- public:
- // Person class constructors
- Person() { name = 0; dd = 0; mm = 0; yyyy = 0; }
- Person(String* n, int d, int m, int y)
- {
- name = n;
- dd = d; mm = m; yyyy = y;
- }
- // The Name property
- __property String* get_Name() { return name; }
- __property void set_Name(String* s) { name = s; }
- // The read-only Age property
- __property int get_Age()
- {
- DateTime now = DateTime::get_Now();
- return now.get_Year() - yyyy;
- }
- };
- // This is the entry point for this application
- #ifdef _UNICODE
- int wmain(void)
- #else
- int main(void)
- #endif
- {
- // Create a Person object
- Person* pp = new Person("fred", 4,9,1955);
- // Access the Name and Age properties
- Console::WriteLine("Age of {0} is {1}", pp->Name, __box(pp->Age));
-
- return 0;
- }