I am new to C++11. In fact until recently, I programmed only using dynamic allocation, in a way similar to Java, e.g.

```
void some_function(A *a){
   a->changeInternalState();
}

A *a = new A();
some_function(a);
delete a;

// example 2
some_function( new A() ); // suppose there is **no** memory leak.

```

Now I want to reproduce similar code with C++11, but without pointers.

I need to be able to pass newly created class `class A` directly to function `useA()`. There seems to be a problem if I want to do so with *non-const* normal reference and It works if I do it with rvalue reference.

Here is the code:

```
#include <stdio.h>

class A{
public:
        void print(){
                ++p; // e.g. change internal state
                printf("%d\n", p);
        }

        int p;
};

// normal reference
void useA(A & x){
        x.print();
}

// rvalue reference
void useA(A && x){
        useA(x);
}

int main(int argc, char** argv)
{
        useA( A{45} );   // <--- newly created class 

        A b{20};

        useA(b);

        return 0;
}

```

It compiles and executes correctly, but I am not sure, if this is the correct acceptable way to do the work?

Are there some best practices for this kind of operations?