c++ - Converting google::protobuf::RepeatedField<float> to float -


i using google's protobuf create c++ class called foo, follows:

message foo {     optional int32 x = 1;     repeated float y = 2; } 

in created c++ class, creates member variable y of type const google::protobuf::repeatedfield<float>. now, in c++ code, want access x , y variables of instance of foo, called foo. in example, y of length one, i.e. contains 1 float:

int = foo.x(); float b = foo.y(); float c = foo.y()[0]; 

here, first line works, errors both second , third lines. trying value of float stored in y.

how should doing this?

thanks!

you want:

float b = foo.y(0); 

(stack overflow complaining answer short...)


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -