sizeof returns the size of the local variable.
If your array is a local variable (on the stack) sizeof(array) will return hw big the array is in bytes. But if you create your array on the heap using new or malloc then all that's local is the address of the array so sizeof(array) now returns the size of the address of the array and not the array itself. Further, if you pass your array to a function as an argument, then all that's passed is the address of the array. So inside the function sizeof(array) again returns the sizeof the address.
You need to maintain a variable that contains the number of elements and pass it around with the array address. This is the only method that works in all cases.
Further, arrays are consdered very low level. C++ users are supposed to use vectors. The vector container is an array but all of the code you need to write to manage your own personal array is duplicated by the vector code. You should just use a vector and save yurself a lot of time writing code that's alreayd been written and debugged.