Memory in class Management CUDA Memory

can I allocate CUDA memory in class attribute and then pass to a function on the cuda kernel?
Like this

MY class

class test{

public:
void *cudaData;

test:test(){
    cudaMalloc( (void**)&cudaData, 10 * sizeof(double));
}

}

And after some time use this memory at kernel functions?

foo<<< 1, size >>>(my_array, m_cudaData);

its works?

It should, yes.