English 中文(简体)
你们如何将病媒变数传递给一种功能? [复制]
原标题:How do you pass a vector variable to a function? [duplicate]
This question already has answers here:
Closed 12 years ago.

Possible Duplicate:
How can I pass a vector variable to a function?

我有以下法典:

std::vector <const char*> value;
value[0] = buf.c_str();

// Now I have to pass the vector variable to function.
// Function declaration: int my_function(const char *)
my_function(value[0]);

然而,我发现这一错误:

差错:不能将<条码>改为: 韦克尔加勒; 果*:平地位置和带;char*> ; <条码>至<条码>,用于第1至<条码>的争论

你们能否帮助我解决这一问题?

问题回答

例如:

typedef std::vector<std::string> myvec;

void func(myvec &vec){

 //use vec
}


main.cpp:

myvec vec;

func(vec);

页: 1 修改声明和定义,并罚款,或可改为cast<>em>。 http://www.ohchr.org。

这样做的唯一安全途径是:发挥你的作用。 在大多数汇编者中,如果你能够把它作为果园地寄出,则可以把它作为果园。

$(vec[0])

正如我所说的那样,这并非安全,因为标准并没有说,病媒需要连续记忆,但随后,摩托制作者将病媒放在连续记忆中。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签