벡터에 :포인터는이 코드를 가지고
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> *vecptr;
int veclen;
void getinput()
{
string temp;
for(int i = 0; i < 3; i++)
{
cin>>temp;
vecptr->push_back(temp);
}
veclen = vecptr->size();
}
int main()
{
getinput();
for(int i = 0; i < veclen; i++)
{
cout<<vecptr[i]<<endl;
}
return 0;
}
제 컴파일러 (G ++) 나에게 몇 가지 오류 던져 : test2.cpp : 28 : 17 : 오류 : '에서'연산자 < < '아무 짝을 std :: cout < < * (vecptr + ((부호없는 int) (부호없는 int) i) * 12u)) '...
무엇이 잘못 되었습니까? 문제를 해결하려면 어떻게해야합니까?
cout << (*vecptr)[i] << endl;
또한 vecptr
를 초기화해야합니다