Managing Implicit Type Conversion in C++

I'm working on code that does nearest-neighbor queries. There are two simple ideas that underlie how a user might query for data in a search: - closest N points to a given point in space. - all points within a given distance. In my code, Points are put into a PointList, and the PointList is a container has the job of keeping track of the points that have been found in the search. Right now my PointList object has one constructor: PointList( unsigned int maxvals ); // #1 The next two constructors that I'd like to add are these: PointList( float maxdist ); // #2 PointList( unsigned int maxvals, float maxdist ); // #3 My question is: how do I ensure that my users and the C++ compiler will generate the right constructor for the PointList and differentiates between constructors 1 and 2? Should I just implement #3 and provide constants that define arbitrary large values for maxvals and maxdist? Another alternative might be to write another system of lightweight objects that govern the logic for adding Points to the list, but that feels like overkill for such a simple idea. I'm really trying to make this transparent for my users, who are mostly scientists who have learned C++ sometimes without the benefit of formal education. Thanks!

以上就是Managing Implicit Type Conversion in C++的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准