typeid 的用法

本文探讨了如何在运行时比较两个对象是否属于同一类型,以及如何验证一个对象是否为特定子类。通过使用 typeid 操作符,可以实现对 C++ 对象类型的灵活检查,这对于类型安全和动态绑定至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Base *bp;
Derived *dp;
// compare type at run time of two objects
if (typeid(*bp) == typeid(*dp)) {
// bp and dp point to objects of the same type
}
// test whether run time type is a specific type
if (typeid(*bp) == typeid(Derived)) {
// bp actually points to a Derived
}
注意,typeid 的操作数是表示对象的表达式——测试 *bp,而不是 bp:

Base *bp = new Derived ;
cout<<typeid(bp)<<endl;   //输出 Class Base *
cout<<typeid(*bp)<<endl;  //输出 Class Derived
下面这段是PHP5.6,如何改成PHP8.4? <?php require_once("include/global.php"); ?> <html> <head> <?php echo getMeta('gb') ?> <title><?php echo $_GLOBAL_CONF['SITE_NAME'] ?></title> </head> <link rel="stylesheet" href="/common.css" type="text/css"> <style> a {color:#616651} .img1 {border:solid 0 black} </style> <BODY link=#cc0000 leftMargin=0 topMargin=0 marginwidth="0" marginheight="0"> <?php require_once("include/header.php"); ?> <?php /* <div id=ad_dl01 style="z-index:1; visibility:visible; width:100px; position:absolute; top:115px; right:5px;"> <table border=0 cellspacing=0 cellpadding=0 width=300 style="table-layout:fixed; word-break:break-all" bgcolor=#d3e9FF> <tr> <td><iframe width="300" height="200" style="border: solid 1px black; width: 600px; height: 30px;" frameborder="0"></iframe></td> </tr> </table> </div> <script type=text/javascript> var step_ratio = 0.1; objs = new Array(); objs_x = new Array(); objs_y = new Array(); function addfollowmark(name, x, y) { i = objs.length; objs[i] = document.getElementById(name); objs_x[i] = x; objs_y[i] = y; } function followmark() { for(var i=0; i<objs.length; i++) { var fm = objs[i]; var fm_x = typeof(objs_x[i]) == 'string' ? eval(objs_x[i]) : objs_x[i]; var fm_y = typeof(objs_y[i]) == 'string' ? eval(objs_y[i]) : objs_y[i]; if (fm.offsetLeft != document.body.scrollLeft + fm_x) { var dx = (document.body.scrollLeft + fm_x - fm.offsetLeft) * step_ratio; dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx)); fm.style.left = fm.offsetLeft + dx; } if (fm.offsetTop != document.body.scrollTop + fm_y) { var dy = (document.body.scrollTop + fm_y - fm.offsetTop) * step_ratio; dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy)); fm.style.top = fm.offsetTop + dy; } fm.style.display = ''; } } addfollowmark("ad_dl01", "document.body.clientWidth-305", 115); setInterval('followmark()',20); </script> */ ?> <center> <table width=95% border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="2"><img src="images/tb_left.jpg" width="2" height="28" /></td> <td background="images/tb_bg.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php if($_SESSION['ss_admin']>0) echo " <form name=loginform method=post action=/login.php> <input type=hidden name=username value='$ss_name'> <input type=hidden name=password value='$ss_password'> "; ?> <tr> <td width="9"> </td> <td width=111><table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="2"><img src="images/tb_sel_left.jpg" width="2" height="28" /></td> <td width="124" align="center" background="images/tb_sel_bg.jpg" class="selmenu">首页 Home</td> <td width="4"><img src="images/tb_sel_right.jpg" width="4" height="28" /></td> </tr> </table></td> <td align="center"><a href=/search.php class="menu">产品 Products</a></td> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/newest class="menu">新产品 New Products</a></td> <td align="center"><span class="bai">|</span></td> <?php /* <td align="center"><a href=/cart.php class="menu">Order</a></td> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/guestbook class="menu">Guestbook</a></td> <td align="center"><span class="bai">|</span></td>*/ ?> <td align="center"><a href=/help/about.php class="menu">联系我们 Contact us</a></td> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/register class="menu">注册 Register</a></td> <?php if($_SESSION['ss_admin']>0){ ?> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/admin class="menu" target=_blank>Admin</a> <input type=submit value=ReLogin style=cursor:hand></td> <?php } ?> <?php if($_SESSION['ss_userid']>0){ ?> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/bill class="menu">Bills</a></td> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/logout.php class="menu">退出 Logout</a></td> <?php }else{ ?> <td align="center"><span class="bai">|</span></td> <td align="center"><a href=/login.php class="menu">登录 Login</a></td> <?php } ?> </tr> <?php if($_SESSION['ss_admin']>0) echo " </form> "; ?> </table></td> <td width="2"><img src="images/tb_right.jpg" width="2" height="28" /></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <form name=searchform action=search.php method=post> <tr> <td width="6"><img src="images/tb_bt_left.jpg" width="6" height="62" /></td> <td background="images/tb_bt_bg.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="266" align="center" valign="top" class="vd" style="font-size:11px;color:#333333"></td> <td height="58" align="center"><select name=key> <option value=model_no <? if($key == "model_no") echo "selected"; ?>>型号 Model No.</option> <option value=name <? if($key == "name") echo "selected"; ?>>名称 Name</option> <option value=features <? if($key == "features") echo "selected"; ?>>规格 Features</option> <option value=description <? if($key == "description") echo "selected"; ?>>说明 Descriptions</option> <option value=fob_port <? if($key == "fob_port") echo "selected"; ?>>港口 Fob Port</option> <option value=color <? if($key == "color") echo "selected"; ?>>颜色 Color</option> <option value=matial <? if($key == "matial") echo "selected"; ?>>材料 Matial</option> </select> 关键词 Keyword:<input type=text size=5 name=value value="<?php echo $value?>"> 产品号 ProductID:<input type=text size=5 name=productid value="<?php echo $productid?>"> <input type=hidden name=typeid value="<?php echo $typeid?>"> <input type=submit name=sub6 value="查找 Search"></td> </tr> </table></td> <td width="7"><img src="images/tb_bt_right.jpg" width="7" height="62" /></td> </tr> </form> </table></td> </tr> </table> <table width=95% border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top" width=350><table width="100%" height="160" border="0" cellpadding="1" cellspacing="1" bgcolor="#F3F1E7"> <tr> <td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding=5> <tr> <td height="22" align="left" bgcolor="#E7E4D2"></td> </tr> <tr> <td height="350" align="left" class="vd"><FONT style=font-size:14px;color:#000000;line-height:22px><?php include "include/html/notice1.html";?><FONT></td> </tr> <tr> <td height="1" bgcolor="#f5f5f5"></td></tr> <tr> <td height="20" align="right"><a href=/help/about.php class="blue" target=_blank>联系我们 Contact Us</a>   |   <a href=/help/about.php class="blue" target=_blank>更多 More</a>   </td> </tr> </table></td> </tr> </table></td> <td width="5"> </td> <td> <table cellspacing=0 cellpadding=0 align="center" bgcolor=#ffffff> <tr><td align=center> <?php /* <font style=font-size:5px><br></font><table border=0 cellspacing=0 cellpadding=0> <tr> <td align=center width=311><img src=images/100001.jpg class=img1><font style=font-size:5px><br><br></font></td> <td bgcolor=#c1c69d width=1></td> <td align=center width=311><table cellspacing=0 cellpadding=0 align="center"> <tr align=center> <td colspan=2 height=5></td> </tr> <tr align=center> <td><a href=search.php?typeid=1001000><img src=images/200001.jpg alt="Molding Case" class=img1></a></td> <td><a href=search.php?typeid=1002000><img src=images/200002.jpg alt="Assembled Case" class=img1></a></td> </tr> <tr align=center> <td><a href=search.php?typeid=1003000><img src=images/200003.jpg alt="Instrument Box" class=img1></a></td> <td><a href=search.php?typeid=1004000><img src=images/200004.jpg alt="Aluminum Box" class=img1></a></td> </tr> </table><font style=font-size:2px><br><br></font></td> </tr> <tr> <td bgcolor=#c1c69d colspan=3></td> </tr> <tr> <td align=center><font style=font-size:5px><br></font><table cellspacing=0 cellpadding=0 align="center"> <tr align=center> <td><a href=search.php?typeid=2001000><img src=images/300001.jpg alt="Premium Bag" class=img1></a></td> <td><a href=search.php?typeid=2002000><img src=images/300002.jpg alt="Casual Bags" class=img1></a></td> </tr> </table></td> <td bgcolor=#c1c69d width=1></td> <td align=center><font style=font-size:5px><br></font><table cellspacing=0 cellpadding=0 align="center"> <tr align=center> <td><a href=search.php?typeid=3001000><img src=images/400001.jpg alt="Solid Wood Item" class=img1></a></td> <td><a href=search.php?typeid=3002000><img src=images/400002.jpg alt="Gift Item" class=img1></a></td> </tr> </table></td> </tr> </table><font style=font-size:5px><br></font>*/?> <a href=search.php><img src=images/01.jpg alt="Enter Please" class=img1 width=600></a> </td></tr> </table> </td> </tr> </table> <table border=0 cellpadding=0 cellspacing=0><form method=POST action=n2e.php target=frame1> <tr><td valign=middle>数字 Num<input type=text SIZE=16 name=id><INPUT TYPE=submit VALUE="英语 EN" NAME=s></td> <td><IFRAME name=frame1 frameBorder=1 width=780 scrolling=no height=26></IFRAME></td></tr></form> </table> <table border=0 cellpadding=0 cellspacing=0><form method=POST action=n2c.php target=frame2> <tr><td valign=middle>数字 Num<input type=text SIZE=16 name=id><INPUT TYPE=submit VALUE="中文 CN" NAME=s></td> <td><IFRAME name=frame2 frameBorder=1 width=780 scrolling=no height=26></IFRAME></td></tr></form> </table> <?php require_once("include/foot.php"); ?> </center> </body> </html>
06-11
<body class="bodystyle"> <div id="append_parent"></div> <div id="ajaxwaitid"></div> <div class="page atta"> {include file="seo/bar" /} <div class="seo-right {if condition='2 != $config.seo_pseudo'}none{/if}" id="seo_right_uphtml"> <style> .seo-right{ right: 30px; width: 90%; background-color:#fff; z-index:666666; border-radius: 4px; height: 810px; } .seo-html dt.tit { width: 60px; padding-left:20px; } </style> <style> li { list-style: none; } .box { position: relative; display: inline; left: 150px; } .top { height: 20px; position: relative; margin-bottom:20px; } .top input { width: 100px; height: 20px; font-size: 25px; padding: 0 20px; border: 1px solid #d1ccd0; outline: none; } .top .blue { border: 2px solid #409eff;; } .top .size { width: 16px; height: 16px; position: relative; top: 50%; left: -30px; margin-top: -8px; transform: rotate(180deg); transition: all .5s; color: #d1ccd0; } .top ul { position: absolute; display:flex; font-size: 10px; top: 50%; transform: translateY(-50%); left: 15px; z-index: 99; } .top ul li { border-radius: 5px; display: none; margin-top: 20px; font-size: 14px; } .arr1{ margin-left: 20px; } .list { width: 100%; height: 430px; margin-top: 5px; background-color:#fff; /* 超出隐藏,需要时加滚动条*/ overflow: auto; position: relative; display: block; z-index:99; } /* 隐藏滚动条 */ .list::-webkit-scrollbar { display: none; } .list-ul { width: 100%; } .header{ background-color: #f7f7f7; clear: both; position: relative; z-index: 1; } .header th{ white-space: nowrap; cursor: default; border-right: 2px solid #fff; box-sizing: border-box; line-height: 35px; } .list-ul > span { flex: 0 0 33.33%; box-sizing: border-box; min-width: 300px; } .list ul { display: flex; flex-direction: column; margin: 8px 0; } .list ul li { display: flex; height: 27px; align-items: center; padding: 0 10px; color: #65676b; cursor: pointer; } .list ul li:hover { background-color: #f5f8ff; } .list ul li label { font-size: 10px; margin-left: 15px; display: block; width: 100%; } .fontBlue { color: #0075ff; } #input1{ width: 300px; height: 30px; padding-right: 6px; padding-left: 6px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #d1ccd0; border-radius: 4px; font-size: 14px; color: #333; margin-bottom: 10px; } #searchInput { width: 136px; height: 20px; padding-right: 6px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #d1ccd0; border-radius: 4px; font-size: 14px; color: #333; margin-right: 20px; } #path-select,#online-status-select,#domain-type-select{ width: 150px; height: 30px; padding-right: 6px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #d1ccd0; border-radius: 4px; font-size: 14px; color: #333; margin-right: 20px; margin-bottom:10px; } table { border-collapse: collapse; } tr { border-bottom: 1px solid #f7f7f7; line-height: 48px; } #temp-select, #temp-type-select{ width: 150px; height: 30px; padding-right: 6px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #d1ccd0; border-radius: 4px; font-size: 14px; color: #333; margin-right: 20px; margin-bottom: 10px;; } #queryButton{ min-height: 20px; padding: 5px 15px; font-size: 12px; border-radius: 3px; } .partial-upload{ margin-left: 10px; padding: 7px 19px!important; } </style> <div class="page" style="padding: 0px 15px 30px"> <form method="get" id="html_handlepost" name="form2"> <div class="ncap-form-default seo-html" style="display: relative;padding: 10px 0px 30px;"> <dl class="row" style="margin-top: 0px"> <dt class="tit" style="height: 30px;font-size:18px;display:block;"> <label>全部域名:</label> </dt> <div class="template_input" style="font-size: 16px;position: relative;left:150px;display:inline-block;margin-bottom:27px;"> <em style="color:#F60;font: bold 14px/20px tahoma, verdana;">*</em> <span>提交template资源文件:</span>   <label for="seo_upload_all_yes" class="curpoin"> <input type="radio" id="seo_upload_all_yes" name="seo_upload_all" value="1"> 是 </label> <label for="seo_upload_all_no" class="curpoin"> <input type="radio" id="seo_upload_all_no" name="seo_upload_all" value="0" checked> 否 </label> <a href="javascript:void(0);" id="up_site" class="partial-upload ncap-btn ncap-btn-green" style="margin-left: 90px;">一键生成全部域名并上传到s3</a> </div> <dd class="opt w0" style="position:relative;left:150px;"> <span class="err"></span> <p class="notic"></p> </dd> </dl> <dl class="row" style="border-top: 1px solid rgb(238,238,238);background-color:#fff;padding-top:23px;display:inline-block;width:100%;margin-bottom:20px;"> <dt class="tit" style="height: 30px;font-size:18px;display:block;">部分域名:</dt> <div class="template_input" style="font-size: 16px;position: relative;left:150px;display:inline-block;margin-bottom:30px"> <em style="color:#F60;font: bold 14px/20px tahoma, verdana;">*</em> <span>提交template资源文件:</span>   <label for="seo_upload_yes" class="curpoin"> <input type="radio" id="seo_upload_yes" name="seo_upload" value="1"> 是 </label> <label for="seo_upload_no" class="curpoin"> <input type="radio" id="seo_upload_no" name="seo_upload" value="0" checked> 否 </label> <a href="javascript:void(0);" id="up_article_multiple" class="ncap-btn ncap-btn-green partial-upload" style="margin-left: 90px;">一键生成所选域名并上传到s3</a> <a href="javascript:void(0);" id="down_article_multiple" class="ncap-btn ncap-btn-green partial-upload" style="margin-left: 45px;">一键下线所选域名</a> </div> <div class="top" style="left:150px;margin-bottom:19px;display: inline-block;margin:0px;"> <input type="text" name="" id="input1" style="display:none;"> <input type="text" id="searchInput" placeholder="域名名称"> <select id="path-select"> <option value="0">域名类型</option> <option value="1">一级</option> <option value="2">二级</option> </select> <select id="online-status-select"> <option value="0">是否上线</option> <option value="1">是</option> <option value="2">否</option> </select> <select id="domain-type-select"> <option value="0">域名类型</option> <option value="1">游戏</option> <option value="2">电商</option> <option value="3">资讯 - 金融</option> <option value="4">资讯 - 科技</option> </select> <select id="temp-type-select"> <option value="0">模板类型</option> <option value="1">info</option> <option value="2">game</option> <option value="3">ecommerce</option> </select> <select id="temp-select"> <option value="0">模板名称</option> </select> <button type="button" id="queryButton">查询</button> <ul style="display:none;"> <li class="change"></li> <li class="arr1"></li> </ul> </div> <dd class="opt w0" style="margin: 30px;"> <div class="box hDivBox"> <div class="list hDiv"> <div class="list-ul hDivBox" style=" overflow-x: auto; width:1500px;"> <table class="header" cellpadding="0" cellspacing="0" style="width: 100%;"> <thead> <tr> <th class="sign w50" axis="col0"> <div class="tc"><input type="checkbox" onClick="toggleCheckboxes(this)" autocomplete="off"></div> </th> <th axis="col3" class="w300"> <div class="sundefined tc">域名名称</div> </th> <th axis="col1" class="w100"> <div class="tc">二级域名</div> </th> <th axis="col1" class="w100"> <div class="tc">上线状态</div> </th> <th axis="col1" class="w160"> <div class="tc">多级目录地址</div> </th> <th axis="col2" class="w160"> <div class="tc">域名类型</div> </th> <th axis="col2" class="w160"> <div class="tc">模板类型</div> </th> <th axis="col2" class="w200"> <div class="tc">模板名称</div> </th> <th axis="col1" class="w200"> <div class="tc">创建时间</div> </th> <th axis="col1" class="w200"> <div class="tc">上次修改时间</div> </th> </tr> </thead> </table> <table class="flex-table autoht" cellpadding="0" cellspacing="0" border="0" id="arctype_table" style="width: 100%"> <tbody class="flex-tbody"></tbody> </table> </div> </div> </div> <p class="notic"></p> </dd> </dl> <dl class="row" style="display: none;"> <dt class="tit">栏目页</dt> <dd class="opt w0"> <select name="html_typeid" id="html_typeid" style="width: 150px;"> <option value="0">所有栏目…</option> {$select_html} </select>  <a href="javascript:void(0);" id="up_channel" class="ncap-btn ncap-btn-green">一键生成</a> <p class="notic"></p> (功能已弃用) </dd> </dl> </div> </form> </div> 这个dd元素已经超出了我的整体范围,导致有一些内容变的不可见了,所以我现在应该怎么办,目前可以实现上下滑动来查看,但是左右滑动实现不了,我不希望使用换行的方式来解决 dd class="opt w0" style="margin: 30px;">
最新发布
08-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值