I haven't tried it but I wouldn't expect your code to compile.
You are describing 3 classes here: Base, NewClass and myClass. Base includes a pointer to myClass, which in your code as provided, is not defined (error). If you somehow overlook this and define it somehow, in the lower section of code:
1 myClass* b;
2 Base me;
Lines 2 and 3 could be combined as
2/3 Base me=NewClass();
which represents use of a copy constructor, building a new 'Base' object, copying elements from a new 'NewClass' temporary object. At this point, me.a is undefined (usually trash from the stack with most compilers). Line 4 should assign me.a the value of b (on the stack) and line 5 will change b->val.
(1) We are talking C++ here. Java for example does something different.
(2) This code segment is external to the classes in question.
(3) myClass contains something named 'val' (which is well formed POD and not a property or something else funky).
You didn't provide the code for class myClass, which could change all of the above.