Let's say I have something that looks like this:
struct foo {
~foo() = delete;
}
And let's say I later dynamically allocate an object of type foo
:
foo *f = new foo;
This is fine; I assume the synthesized default constructor is used to construct the object denoted by f
, however:
foo f2;
Gives me an error:
Attempt to use a deleted function
So how is the object denoted by f
constructed if the default constructor for foo
is implicitly deleted?
Moreover, assuming foo
has the private member size_t n
. What is the value of n
for a dynamically allocated foo
, such as the one denoted by f
?
Aucun commentaire:
Enregistrer un commentaire