c++ - Expected An Expression / Type Name Not Allowed -


brixpath::brixpath(){ {    _animationoptions = (animationoptions){5, 3, 40, 30};  }; 

when run code block vs gives error

typename not allowed on animationoptions.

when remove typename

brixpath::brixpath(){ {    _animationoptions = {5, 3, 40, 30};  }; 

vs2010 gives error @ 1st "{" in 2nd line

error: expected expression

the definition of animation options is-

struct animationoptions { int maxclicks; //how many clicks animation on screen support int step; // animation speed, 3 pixels per time int limit; //width of animation rectangle. if more, rectangle dissapears int distance; //minimum distance between previous click , current }; 

how solve error? please help.

given user of vs 2010 (i.e., can't use c++11 uniform initialization), want add constructor struct, use initialize structure:

struct animationoptions {     int maxclicks; //how many clicks animation on screen support     int step; // animation speed, 3 pixels per time     int limit; //width of animation rectangle. if more, rectangle dissapears     int distance; //minimum distance between previous click , current      animationoptions(int maxclicks, int step, int limit, int distance) :          maxclicks(maxclicks), step(step), limit(limit), distance(distance) {} };  brixpath::brixpath() : _animationoptions(5, 3, 40, 30) {} 

if need maintain animationoptions pod, believe can simplify code bit braced initialization rather member-wise initialization:

animationoptions make_ao(int clicks, int step, int limit, int distance) {   animationoptions ao = {clicks, step, limit, distance};   return ao; }; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -