is it possible to initialize a structure via initializer list

is it possible to initialize an structure using the constructor initialize list. i tried this but it doesnt work.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct test
{
    int varone;
    int vartwo;
};

class example
{
public:
    example(int one, int two) : mtest.varone(one) , mtest.vartwo(two) {}


private:
    test mtest;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct test
{
    test( int one, int two ) : varone( one ), vartwo( two ) {}
    int varone;
    int vartwo;
};

class example
{
    public:
        example( int one, int two ) : mtest( one, two ) {}
    private:
        test mtest;
};

oh i see. ok thanks for the fast reply.
Topic archived. No new replies allowed.