RefArray.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;
- // This is the entry point for this application
- #ifdef _UNICODE
- int wmain(void)
- #else
- int main(void)
- #endif
- {
- Console::WriteLine(S"Arrays of Reference Types");
- // Create an array of String references
- String* pa[] = new String*[5];
- // Explicitly assign a new String to element zero
- pa[0] = new String("abc");
- // Implicitly assign a new String to element one
- pa[1] = "def";
- // Print the array content
- for(int i=0; i<5; i++)
- {
- if (pa[i] == 0)
- Console::WriteLine("null");
- else
- Console::WriteLine(pa[i]);
- }
- return 0;
- }