In C++ you would avoid a naked new and either create a shared/unique pointer with std::make_shared/std::make_unique in C++11/14 or encapsulate the allocation in a handle-class following the RAII idiom.
To give an example of how that would work:
class Foo {
const int i;
public:
int j;
Foo(int i) : i{i}, j{0} {}//constructor
void foo() {std::cout << i << "\n";}
};
int main() {
unique_ptr<Foo> fp = make_unique<Foo>(5);
fp->foo();
return 0;
}
In case the constructor looks a bit confusing to you, a short explanation: The colon after the constructors signature starts the initialization declaration. In this section you have to initialize const-values, but you can initialize all values there. Thus constructors, which take arguments often look like this:
Foo(ArgType1 arg1, ArgType2 arg2,...,ArgTypeN argN) :
member1(arg1), member2(arg2), ... , memberN(argN) {//empty body}
Be sure to pay attention to the rule of three/five, when writing constructors.