V
Verbal Kint
Hallo everybody,
I am having a short question here which I can not answer myself. The
problem is, that I would like to give a vector to a class and modify
the vector with the help of the functions of the class. All the changes
inside the class should effect also the original vector.
In the following I am having a very limited code, that shows what I did
until now. But how to modify this code, so that all changes take place
outside the class? Is it possible to do this without giving the vector
as address operator in the constructor?
Thanks.
V.K.
class ClassA
{
public:
void SDat (vector <int> dat)
{
itsDat = dat;
}
private:
vector <int> itsDat;
};
int main()
{
int i;
ClassA CLASS;
std::vector <int> dat;
for (i=0;i<10;i++)
dat.push_back(i);
CLASS.SDat(dat);
return 0;
}
I am having a short question here which I can not answer myself. The
problem is, that I would like to give a vector to a class and modify
the vector with the help of the functions of the class. All the changes
inside the class should effect also the original vector.
In the following I am having a very limited code, that shows what I did
until now. But how to modify this code, so that all changes take place
outside the class? Is it possible to do this without giving the vector
as address operator in the constructor?
Thanks.
V.K.
class ClassA
{
public:
void SDat (vector <int> dat)
{
itsDat = dat;
}
private:
vector <int> itsDat;
};
int main()
{
int i;
ClassA CLASS;
std::vector <int> dat;
for (i=0;i<10;i++)
dat.push_back(i);
CLASS.SDat(dat);
return 0;
}