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:
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.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; }
- SirCrono6
P.S. Googled and board searched