计算机类

说出下面几个函数的区别:private void test(string str){…}private void test(ref string str){…}private void test(out string str){…}如果一个页面与数据

题目

说出下面几个函数的区别:

private void test(string str){…}

private void test(ref string str){…}

private void test(out string str){…}

如果一个页面与数据

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

已知类 String 的原型为

class string

{

public:

string(const char *str=null);//普通构造函数

string(const string &other);//拷贝构造函数

---string(void);

string &operate=(const string &other);//赋值函数

private:

char * m-data;//用于保存字符串

};

请编写 string 的上述4 个函数


正确答案:
 

第2题:

void GetMemory(char *p){p = (char *)malloc(100);}void Test(void) {char *str

= NULL;GetMemory(str); strcpy(str, "hello world");printf(str);}请问运行 Test 函数

会有什么样的结果?


正确答案:
 

第3题:

publicclassTest {}Whatistheprototypeofthedefaultconstructor?()

A.Test()

B.Test(void)

C.publicTest()

D.publicTest(void)

E.publicvoidTest()


参考答案:C
ThecorrectanswertothisquestionisC.Thedefaultconstructoralwaystakesthesameaccessoftheclass.Inthiscase,theclassispublicandsodoesthedefaultconstructor.

第4题:

编写类 String 的构造函数、析构函数和赋值函数

已知类 String的原型为:

class String

{

public:

String(const char *str = NULL); // 普通构造函数

String(const String &other); // 拷贝构造函数

~ String(void); // 析构函数

String & perate =(const String &other); // 赋值函数

private:

char *m_data; // 用于保存字符串

};

请编写 String的上述 4 个函数。


正确答案:
 

第5题:

Void GetMemory2(char **p, int num){*p = (char *)malloc(num);}void

Test(void){char *str = NULL;GetMemory(&str, 100);strcpy(str, "hello"); printf(str); }请问

运行Test 函数会有什么样的结果?


正确答案:
 

第6题:

char*getmemory(void)

{ char p[]=”hello world”;

return p;

}

void test(void)

{

char *str=null;

str=Getmemory();

printf(str);

} 请问运行 Test 函数会有什么样的结果.


正确答案:
 

第7题:

char *GetMemory(void){ char p[] = "hello world";return

p; }void Test(void){char *str = NULL;str = GetMemory(); printf(str);}请问运行 Tes

t 函数会有什么样的结果?


正确答案:
 

第8题:

void setmemory(char **p, int num)

{ *p=(char *) malloc(num);}

void test(void)

{ char *str=NULL;

getmemory(&str,100);

strcpy(str,"hello");

printf(str);

}

运行test函数有什么结果?( )


正确答案:
 

第9题:

void Test(void){char *str = (char *)

malloc(100); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “

world”); printf(str);}}请问运行 Test 函数会有什么样的结果?


正确答案:
 

第10题:

下面程序的结果是 include class test{private: int num; publi

下面程序的结果是 #include<iostream.h> class test{ private: int num; public: test( ); int getint( ) {return num;} ~test( );}; test::test( ) { num=0;} test::~test( ) { cout<<"Destructor is active"<<endl;} void

A.Exiting main Destructor is active Destructor is active Destructor is active

B.Exiting main Destructor is active Destructoris active

C.Exiting main Destructoris active

D.Exiting main


正确答案:A
解析:C++语言中析构函数是在程序退出不用该类的对象时进行调用。