从函数返回动态数组 [英] returning dynamic array from function

查看:109
本文介绍了从函数返回动态数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

newInfo [0]的输出为空白。它应该是记录号

The output for newInfo[0] is blank. it should be the record number

展开 | 选择 | Wrap | 行号

推荐答案

返回指向局部变量的指针(在这种情况下,字符串)不好 - 它可能会在返回后的任何时间被覆盖。
Returning a pointer to a local variable (in this case, string) is not good - it may be overwritten in any time after return.


尝试使用关联调试器调试软件。


顺便问一下这条线是什么?
ss<< recordSelected;


什么是 recordSelected 的var类型。我不知道如何

ss<< recordSelected; 的。如果 recordSelected 是任何类型的数字(int,long)类型变量并且ss是字符串,则检查此行是否正常工作..
Try debugging your software with the associate debugger.

By the way what is this line?
ss << recordSelected;

what is var type of recordSelected. I dont know how

ss << recordSelected;. If recordSelected is any kind of number(int, long) type variable and ss is string then check whether this line work at all..


为什么不使用矢量而不是所有这些数组的东西?所有向量都是一个已经编写和调试过控制代码的数组,所以你不必为自己的数组反复进行。
Why not use a vector instead of all this array stuff? All the vector is is an array that has the control code already written and debugged so you don''t have to do it over and over and over for your own arrays.


这篇关于从函数返回动态数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆