小编use*_*404的帖子

MySQL Function to Determine Zip Code Proximity/Range

I have been able to create php function to determine a list of zip codes within a certain range of a given zip code. However, my next task is a bit more complex.

Lets say the table has the following columns:

id,
username
info
latitude
longitude
range
Run Code Online (Sandbox Code Playgroud)

Each record has a unique row id, some information, a latitude, a longitude, and a maximum range from those coordinates that the person wants this entry to be found for. So, if I …

php mysql zipcode function proximity

4
推荐指数
1
解决办法
1309
查看次数

在实例化期间为c ++类变量设置变量类型

我有一个c ++类,如下所示:

class some_class {

    protected:
        decide_later some_variable;

    public:
        void some_random_function();

};

void some_class::some_random_function() {

    decide_later another_variable;

}
Run Code Online (Sandbox Code Playgroud)

问题是,在创建类的实例之前,我不知道some_variable将是什么变量类型.我想做的是如下:

some_class class_instance(std::string);
Run Code Online (Sandbox Code Playgroud)

这会将decision_later设置为使用std :: string(或int,或double,或者告诉它使用的任何东西).另外,如果我可以在其他作为类成员的函数中使用decision_later作为变量类型,那将是很好的.例如,在函数some_random_function()中.

我曾尝试使用boost :: any来做到这一点,但它似乎只适用于数字类型.此外,我认为如果能够实际设置实际的变量类型会更有效率.

这可能吗?

c++ variables variable-types

3
推荐指数
1
解决办法
398
查看次数

从纬度和长度中查找一定范围内的一组坐标

我正在开发一个涉及谷歌地图的JavaScript项目.

目标是在一组纬度经度坐标的n公里内找出16-20个坐标点,使得如果连接的16个点将围绕原始坐标形成圆.

最终的目标是使它能够找到坐标以绘制和连接谷歌地图,以围绕给定的坐标集创建一个圆圈.

代码将类似于:

var coordinates = Array();
function findCoordinates(lat, long, range) {
}
coordinates = findCoordinates(-20, 40, 3);
Run Code Online (Sandbox Code Playgroud)

现在让魔法发生在findCoordinates()函数中.

javascript google-maps latitude-longitude coordinates

2
推荐指数
1
解决办法
9746
查看次数

在c ++中将字符串转换为函数

我一直在寻找一种方法将函数动态加载到c ++中一段时间​​,我想我终于搞清楚了.这是计划:

  1. 将函数作为字符串传递给C++(通过套接字连接,文件或其他东西).
  2. 将字符串写入文件.
  3. 让C++程序编译并执行它.如果有任何错误,请抓住并返回.
  4. 使用新函数新执行的程序将函数的内存位置传递给当前正在运行的程序.
  5. 将函数的位置保存到函数指针变量(函数将始终具有相同的返回类型和参数,因此这简化了指针的声明).
  6. 使用函数指针运行新函数.

问题是,在第4步之后,我不想保持新程序运行,因为如果我经常这样做,许多正在运行的程序将会吸收线程.有没有办法关闭新程序,但保留存储新功能的内存位置?我不希望它在被使用时被覆盖或提供给其他程序.

如果你们对其他步骤也有任何建议,那也值得赞赏.可能还有其他库可以做与此类似的事情,可以推荐它们,但这是我想要研究的方法 - 如果不是为了完成它,那么知道如何这样做.

编辑:我知道动态链接库.这是我正在深入研究的内容,以便更好地理解C++中的工作原理.

c++ memory-management

0
推荐指数
1
解决办法
146
查看次数