问两个巨弱的C++问题
1.将数组的引用作为函数的参数,改如何写?比如:
#include <iostream>
int main(int argc, char* argv[])
{
void printM(std::string [] &, int); //函数申明
std::string m[12];
for (int i = 0; i < 12; i++)
m[i] = "asdjfaldsf";
printM(&m, 12); //调用函数
return 0;
}
void printM(std::string & sp[12], int i) //函数定义
{
.........................
}
请问在这个函数的申明,定义以及调用中,这个数组的引用作为参数该如何写?
2。#include <iostream>
std::string sWord;
cin >> sWord; //这里有错
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
Error executing cl.exe.
为何有错?
谢谢1