小编joh*_*een的帖子

这个const引用std :: pair如何工作?

考虑std::mapSTL中的类:

template < class Key,                                     // map::key_type
           class T,                                       // map::mapped_type
           class Compare = less<Key>,                     // map::key_compare
           class Alloc = allocator<pair<const Key,T> >    // map::allocator_type
           > class map;
Run Code Online (Sandbox Code Playgroud)

迭代器std::map返回类型的对象

std::pair<const key_type, T>
Run Code Online (Sandbox Code Playgroud)

这里要注意的重要一点是,该对中的第一个成员是const。这意味着以下参考分配无效

std::pair<key_type, T>& reference = *map_iterator;        // Incorrect, key_type is not const

std::pair<const key_type, T>& reference = *map_iterator;  // Correct
Run Code Online (Sandbox Code Playgroud)

但是,以下表达式有效

const std::pair<key_type, T>& reference = *map_iterator;  // Correct, const reference is okay
Run Code Online (Sandbox Code Playgroud)

因此,通过某种机制,std::pair<const key_type, T>可以通过引用type引用type的对象 …

c++ stl const std-pair

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

mysql_query()的问题;说预期的资源

我有这个php文件.标记为粗体的行显示错误:"mysql_query()将参数2作为资源使用.嗯,在我评论过的行上的类似语法'没有错误??' 工作得很好.

 function checkAnswer($answerEntered,$quesId)
 {
  //This functions checks whether answer to question having ques_id = $quesId is satisfied by $answerEntered or not

  $sql2="SELECT keywords FROM quiz1 WHERE ques_id=$quesId";
  **$result2=mysql_query($sql2,$conn);**
  $keywords=explode(mysql_result($result2,0));

  $matches=false;
  foreach($keywords as $currentKeyword)
  {
   if(strcasecmp($currentKeyword,$answerEntered)==0)
   {
    $matches=true;
   }
  }

  return $matches;

 }

 $sql="SELECT answers FROM user_info WHERE user_id = $_SESSION[user_id]";
 $result=mysql_query($sql,$conn);         // No error??
 $answerText=mysql_result($result,0);

 //Retrieve answers entered by the user
 $answerText=str_replace('<','',$answerText);
 $answerText=str_replace('>',',',$answerText);
 $answerText=substr($answerText,0,(strlen($answerText)-1));
 $answers=explode(",",$answerText);

 //Get the questions that have been assigned to the user.
 $sql1="SELECT questions FROM user_info …
Run Code Online (Sandbox Code Playgroud)

php mysql

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

在空表上的PHP中的SQL查询返回什么?

我有以下PHP脚本:

 <?php
       $all_threads=mysql_query("SELECT * FROM forum_threads WHERE category=$_GET[id]");

       if($all_threads){ ?>
            //Do something.
     <?php
       }
       else { ?>
            //Do something else
      <?php
       } ?>
Run Code Online (Sandbox Code Playgroud)

表forum_threads为空,因此查询应根据http://php.net/manual/en/function.mysql-query.php中的文档返回'false',并且'else'块应该被执行.然而,奇怪的是,if-block正在执行.怎么会?

php mysql

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

为什么链接器在任何地方都没有指定时寻找 python36_d.lib?

我正在使用 VS 2017 和 SWIG编译 Python C++扩展模块

扩展模块(.pyd 文件)的链接器(用于调试配置)的命令是:

/OUT:"D:\TFS\Dev\CGALSwig\cgal-swig-binding-4.x\build\build-python\CGAL\_CGAL_Kernel.pyd" /MANIFEST /NXCOMPAT /PDB:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/_CGAL_Kernel.pdb" /DYNAMICBASE "C:\Users\helloworld\AppData\Roaming\python\libs\python36.lib" "Debug\CGAL_Kernel_cpp.lib" "D:\TFS\Dev\CGALSwig\mpfr\lib\libmpfr-4.lib" "D:\TFS\Dev\CGALSwig\gmp\lib\libgmp-10.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/Debug/CGAL_Kernel.lib" /DEBUG /DLL /MACHINE:X64 /INCREMENTAL /PGD:"D:\TFS\Dev\CGALSwig\cgal-swig-binding-4.x\build\build-python\CGAL\_CGAL_Kernel.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"_CGAL_Kernel_python.dir\Debug\_CGAL_Kernel.pyd.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL" /LIBPATH:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/Debug" /TLBID:1 
Run Code Online (Sandbox Code Playgroud)

这清楚地表明依赖关系是在python36.lib而不是python36_d.lib。尽管如此,链接器仍会引发此错误:

LNK1104 : cannot open file 'python36_d.lib'
Run Code Online (Sandbox Code Playgroud)

当调试 LIB 不在链接器参数中时,为什么链接器要寻找调试 LIB?

c++ python swig

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

jquery .click函数没有被触发

我有以下HTML和Javascript代码.我正在尝试建立一个搜索建议系统.当用户在输入框'site_search'中键入并插入时,使用ajax动态检索无序列表'search_suggest'中的列表项.

<form name="search_site_form" method="get" action="search.php">
        <input id="site_search" name="q" class="search_input input" autocomplete="off" value="Search the site" type="text"/>

    <ul id="search_suggest">
    </ul>
    <input value=" " type="submit" class="search_submit"/>
    <script type="text/javascript">
    <!--
        $("ul#search_suggest>li").click(function(){ 
        alert('123');
    });
    //-->
    </script>
</form>
Run Code Online (Sandbox Code Playgroud)

但是,单击search_suggest中的列表项不会触发单击功能.知道为什么吗?

javascript jquery click jquery-selectors

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

在FPDF中获取扩展名为.pdf的输出文件

这个问题适用于那些使用PHP库FPDF(http://www.fpdf.org)使用PHP生成PDF文档的人.我正在使用php文件'my_file.php'生成PDF文件.我希望用户能够下载该PDF文件.但是在浏览器中,请将地址栏中的文件看作..somepath ..../my_file.php.我希望他们将其视为扩展名为.pdf的文件.知道如何做到这一点?

php fpdf

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

想在网站上显示日出/日落时间

在我的网站上,我想显示该人打开网页的地方的日出和日落时间.现在,如果您按照以下方式搜索,Google Web搜索会提供日出和日落时间:http://www.google.com/search?q=sunrise:<city_name>.我如何使用它在我的网站上提供此功能?

time

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

标签 统计

php ×3

c++ ×2

mysql ×2

click ×1

const ×1

fpdf ×1

javascript ×1

jquery ×1

jquery-selectors ×1

python ×1

std-pair ×1

stl ×1

swig ×1

time ×1