《面向对象与C++》上机作业.docVIP

  • 340
  • 0
  • 约4.52千字
  • 约 5页
  • 2017-02-17 发布于北京
  • 举报
《面向对象程序设计与C++》作业 王 涛 教材:《C++语言程序设计》 郑莉等著 清华大学出版社 2003.12 注:作业中的题号为教材中对应的题号。 第二章 指针与内存分配 1. void Func(char str[100]) { sizeof(str) = ? } char* p = new char[100]; sizeof(p) = ? 为什么? 2. void GetMemory(char* p) { p = new char[100]; } void Test() { char * str = NULL; GetMemory(str); strcpy(str, “hello world”); printf(“%s”, str); } 请问运行Test函数会有什么样的结果?为什么? 3. char * GetMemory(){ char p[] = “hello world”; return p; } void Test(){ char *str = GetMemory(); printf(“%s”, str); } 请问运行Test函数会的到什么样的结果?为什么? 4. void GetMemory(char**

文档评论(0)

1亿VIP精品文档

相关文档