That may well be silly, but I'm going crazy here ..
Why does pTest doesnt point on the new int after test function in main ? It causes seg fault. And how can I do it.
In my real code I need to pass a pointer and dynamically create the object because pTest is a subclass of a virtual class (reading from file so I don't know in advance)
void test(int* pTest)
{
int *p = new int(2);
pTest = p;
std::cout << "pTest : " << *pTest << std::endl;
return;
}
int main()
{
int *pTest = NULL;
test(pTest);
std::cout << "pTest : " << *pTest << std::endl;
return 0;
}