Hello,
I am having trouble in using the data member of class 1 in the member function of another class 2. Following is my code.
class a {
public:
a();
~a();
std::vector<int> temp;
};
class b {
public:
b();
~b();
int test();
}
b::b()
{
a *a1;
a1 = new a();
}
b::test()
{
a *a2;
a2->temp.size(); // Error here.
}
int main()
{
b *b1;
b1 = new b();
return 0;
}
I am creating a new pointer for the class 'a' inside the function of another class 'b'. Is that wrong. What would be the right way to do so.
Any help is really appreciated.
Thanks