/* simple class that has a vector of ints within it */
class A
{
public:
vector<int> int_list;
};
/* some function that just returns an int, defined elsewhere */
int foo();
/* I want to fill the object's int_list up */
A a_obj;
int main() {
for (int i = 0; i < 10; i++) {
int num = foo();
a_obj.int_list.push_back(num);
}
}
범위는 num
for 루프로 제한됩니까? for 루프가 종료되면 파손됩니까? a_obj
에있는 번호에 액세스하려고 시도하면 int_list
안에있는 번호가 파괴되어서 못하게됩니까?내 변수의 범위와 관련하여 약간의 설명이 필요함
대단히 감사합니다. 그게 내가 필요한 것입니다. – martega
@martega : 알아요 :) –