List of initializers for a heap-allocated structure
I have a Visual Studio 2008 C ++ project where I would like a bunch of highlighting a struct and initializing it with an initializer list.
class Foo {
public:
explicit Foo( int a );
};
struct Bar {
Foo foo;
int b;
};
Bar a = Bar { Foo( 1 ), 2 }; // Works!
Bar* b = new Bar{ Foo( 1 ), 2 }; // Errors!
Is there a way to do this?
+3
source to share
3 answers