Another Dynamic Memory Question
According to the book I read on C++, variables in dynamic memory are availiable to functions other than the one it was defined in... take this code:
Code:
#include <iostream>
class Hello
{
public:
int ello;
Hello() { Hello = 10; }
~Hello() {}
};
void Func()
{
std::cout << h->ello;
}
int main( void )
{
Hello* h = new Hello;
Func();
delete h;
return 0;
}
Dev-C++ gives me the error that in Func() h is undeclared... so I'm thinking my understanding of dynamic memory (my book) is wrong, and I would like to know what is wrong about it.
- SirCrono6
P.S. Googled and board searched :)