First and foremost this is a thread for the beginners section not the lounge.
That said if you are programming in C++ you should be using new/delete instead of malloc/free. Though if you do want to use malloc you have to remember that malloc returns a void pointer but you can cast that pointer to your desired type. In C you don't need to do this casting but C++ is a Strongly Typed Language so you need to do a explicit cast to tell the compiler that this is actually what you want to do because it won't implicitly do it for you.
I would suggest moving this thread to the beginners section and then maybe providing more of your code so we can be sure where your problem is.