上一页 1 ··· 47 48 49 50 51

2009年10月25日

strcpy和strlen

摘要: 找错void test2(){char string[10], str1[10];int i;for(i=0; i<10; i++){str1[i] = 'a';}strcpy( string, str1 );}如果面试者指出字符数组str1不能在数组内结束可以给3分;如果面试者指出strcpy(string, str1)调用使得从str1内存起复制到string内存起所复制的字节数具有不确定性可以给7分,在此基础上指出库函数strcpy工作方式的给10 分;char * strcpy( char *strDest, const char *strSrc ){assert 阅读全文

posted @ 2009-10-25 15:26 java课程设计 阅读(352) 评论(0) 推荐(0)

构造函数和析构函数调用顺序

摘要: #include<iostream.h> class A { public: static int num; A(){cout<<num++;} ~A(){cout<<num--;} }; int A::num=0; class B:public A { public: B(){cout<<num++;} ~B(){cout<<num--;} A f(A a){return a;} }; int main() { A a; B b; b.f(b); return 0; } 阅读全文

posted @ 2009-10-25 15:25 java课程设计 阅读(211) 评论(0) 推荐(0)

auto_ptr和operator new

摘要: #include <memory>#include <iostream>#include <cstddef>using namespace std;class TraceHeap { int i;public: static void* operator new(size_t siz) { void* p = ::operator new(siz); cout << "Allocating TraceHeap object on the heap " << "at address " <& 阅读全文

posted @ 2009-10-25 15:25 java课程设计 阅读(188) 评论(0) 推荐(0)

上一页 1 ··· 47 48 49 50 51

导航