📄 key_aspects_of_c++.htm
字号:
<p>Example. Overloaded Operators</p><p>ACIS makes use of the fact that C++ is a strongly typed to enforce rules of combination SPAvector instance.</p><pre class="source-cpp">C++ Example <span class="kw5">SPAposition</span> p1 <span class="br0">(</span><span class="nu0">3</span>, <span class="nu0">4</span>, <span class="nu0">5</span><span class="br0">)</span>; <span class="kw5">SPAposition</span> p2 <span class="br0">(</span><span class="nu0">6</span>, <span class="nu0">7</span>, <span class="nu0">8</span><span class="br0">)</span>; <span class="kw5">SPAposition</span> p3 = p1 + p2; <span class="co1">// Error: this does not compile SPAvector v1 (10, 20 , 30); SPAposition p4 = p1 + v1; // creates a new position offset from // position p1 by vector v1.</span></pre><p>Example. Using C++ Strong Types</p><a name="Overloading_Class_new_and_delete"></a><h2> <span class="mw-headline"> Overloading Class new and delete </span></h2><p>ACIS overloads the C++ new operator to allocate space on the portion of the heap controlled by ACIS ENTITY defines its own new and delete operators that the ACIS free list manager. (These operators are supplied by the ENTITY_FUNCTIONS and UTILITY_DEF macros.)</p><p>When working with Microsoft Developer Studio and/or MFC, the beginning of the file may have been enhanced by Microsoft during a _DEBUG compile. Sometimes you will see:</p><pre class="source-cpp">_DEBUG <span class="kw3">new</span> <span class="kw7">DEBUG_NEW</span> <span class="co1">// ... other code...</span></pre><p>This interferes with the ACIS overloading of new for the entities ENTITY objects to another file.</p><p>In fact it is an issue when trying to instantiate any object derived from an ACIS entity in MFC API_END around the ENTITY creation code, so it is best to do the allocation in an API function.</p><pre class="source-cpp"><span class="kw5">outcome</span> api_make_attrib<span class="br0">(</span><span class="kw7">ENTITY</span>*& ent, <span class="kw7">ATTRIB_GEN_INTEGER</span>*& attrib, <span class="kw4">char</span>*& name, int& value<span class="br0">)</span> <span class="br0">{</span> <span class="kw6">API_BEGIN</span> <span class="kw3">new</span> attrib = <span class="kw3">new</span> <span class="kw7">ATTRIB_GEN_INTEGER</span><span class="br0">(</span>ent, name, value<span class="br0">)</span>; <span class="kw3">new</span> <span class="kw7">DEBUG_NEW</span> <span class="kw6">API_END</span> <span class="br0">}</span></pre><a name="Overloading_API_Functions"></a><h2> <span class="mw-headline"> Overloading API Functions </span></h2><p>Although the discussion so far in this section has been about C++ classes and their associated data elements and methods, much of this holds true for the API function interface.</p><p>The API functions form the primary interface to ACIS and add an additional level of interface stability. Class methods may change from release to release. However, the API interface remain consistent from release to release. The API functions are often wrappers for C++ class methods or groupings of methods.</p><p>Like C++ class methods, API functions can be overloaded. This means that a single name can refer to multiple forms of an API function, with the differences being in the number of arguments and/or in the argument types. The distinction between the overloaded forms of API functions happens at compile time.</p><!-- Tidy found serious XHTML errors --><!-- Saved in parser cache with key r18_docdb-r18doc_:pcache:idhash:451-0!1!0!!en!2!edit=0 and timestamp 20080624033223 --><div class="printfooter">Retrieved from "<a href="http://doc.spatial.com/r18/index.php/Key_Aspects_of_C%2B%2B">http://doc.spatial.com/r18/index.php/Key_Aspects_of_C%2B%2B</a>"</div> <div id="catlinks"><p class='catlinks'><a href="/r18/index.php/Special:Categories" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/r18/index.php/Category:ACIS_Docs" title="Category:ACIS Docs">ACIS Docs</a></span> | <span dir='ltr'><a href="/r18/index.php/Category:ACIS_Getting_Started" title="Category:ACIS Getting Started">ACIS Getting Started</a></span></p></div> <!-- end content -->
<div class="visualClear"></div>
</div>
</div>
</div>
<div id="column-one">
<div id="p-cactions" class="portlet">
<h5>Views</h5>
<div class="pBody">
<ul>
<li id="ca-nstab-main" class="selected"><a href="/r18/index.php/Key_Aspects_of_C%2B%2B" title="View the content page [c]" accesskey="c">Article</a></li>
<li id="ca-talk" class="new"><a href="/r18/index.php?title=Talk:Key_Aspects_of_C%2B%2B&action=edit" title="Discussion about the content page [t]" accesskey="t">Discussion</a></li>
<li id="ca-viewsource"><a href="/r18/index.php?title=Key_Aspects_of_C%2B%2B&action=edit" title="This page is protected. You can view its source. [e]" accesskey="e">View source</a></li>
<li id="ca-history"><a href="/r18/index.php?title=Key_Aspects_of_C%2B%2B&action=history" title="Past versions of this page. [h]" accesskey="h">History</a></li>
</ul>
</div>
</div>
<div class="portlet" id="p-personal">
<h5>Personal tools</h5>
<div class="pBody">
<ul>
<li id="pt-login"><a href="/r18/index.php?title=Special:Userlogin&returnto=Key_Aspects_of_C%2B%2B" title="You are encouraged to log in, it is not mandatory however. [o]" accesskey="o">Log in / create account</a></li>
</ul>
</div>
</div>
<div class="portlet" id="p-logo">
<a style="background-image: url(/r18/images/SpatialCorpLogo.gif);" href="/r18/index.php/Main_Page" title="Visit the Main Page [z]" accesskey="z"></a>
</div>
<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
<div class='portlet' id='p-navigation'>
<h5>Navigation</h5>
<div class='pBody'>
<ul>
<li id="n--Home"><a href="http://doc.spatial.com/ "> Home</a></li>
<li id="n-mainpage"><a href="/r18/index.php/Main_Page" title="Visit the Main Page [z]" accesskey="z">Main Page</a></li>
<li id="n-recentchanges"><a href="/r18/index.php/Special:Recentchanges" title="The list of recent changes in the wiki. [r]" accesskey="r">Recent changes</a></li>
<li id="n-randompage"><a href="/r18/index.php/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
<li id="n-help"><a href="/r18/index.php/Help:Contents" title="The place to find out.">Help</a></li>
</ul>
</div>
</div>
<div class='portlet' id='p-spatial_sites'>
<h5>spatial sites</h5>
<div class='pBody'>
<ul>
<li id="n--Spatial.com"><a href="http://www.spatial.com "> Spatial.com</a></li>
<li id="n---Online-Support-Center"><a href="http://spatial.custhelp.com/cgi-bin/spatial.cfg/php/enduser/acct_login.php?p_sid=tblNMDHh&p_lva=&p_sp=&p_li=&p_next_page=std_alp.php"> Online Support Center</a></li>
<li id="n--Community-Forum"><a href="http://forums.spatial.com/ "> Community Forum</a></li>
<li id="n--Downloads"><a href="http://www.spatial.com/products/download.html "> Downloads</a></li>
<li id="n--Feedback"><a href="mailto:docfeedback_spatial@3ds.com "> Feedback</a></li>
</ul>
</div>
</div>
<div class='portlet' id='p-products'>
<h5>products</h5>
<div class='pBody'>
<ul>
<li id="n-ACIS-Tutorials---Beta"><a href="/r18/index.php/Tutorial:ACIS_Tutorials">ACIS Tutorials - Beta</a></li>
<li id="n-InterOp"><a href="/r18/index.php/Portal:InterOp">InterOp</a></li>
</ul>
</div>
</div>
<div id="p-search" class="portlet">
<h5><label for="searchInput">Search</label></h5>
<div id="searchBody" class="pBody">
<form action="/r18/index.php/Special:Search" id="searchform"><div>
<input id="searchInput" name="search" type="text" title="Search DocR18 [f]" accesskey="f" value="" />
<input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" />
<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" />
</div></form>
</div>
</div>
<div class="portlet" id="p-tb">
<h5>Toolbox</h5>
<div class="pBody">
<ul>
<li id="t-whatlinkshere"><a href="/r18/index.php/Special:Whatlinkshere/Key_Aspects_of_C%2B%2B" title="List of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
<li id="t-recentchangeslinked"><a href="/r18/index.php/Special:Recentchangeslinked/Key_Aspects_of_C%2B%2B" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
<li id="t-specialpages"><a href="/r18/index.php/Special:Specialpages" title="List of all special pages [q]" accesskey="q">Special pages</a></li>
<li id="t-print"><a href="/r18/index.php?title=Key_Aspects_of_C%2B%2B&printable=yes" title="Printable version of this page [p]" accesskey="p">Printable version</a></li> <li id="t-permalink"><a href="/r18/index.php?title=Key_Aspects_of_C%2B%2B&oldid=1133" title="Permanent link to this version of the page">Permanent link</a></li> </ul>
</div>
</div>
</div><!-- end of the left (by default at least) column -->
<div class="visualClear"></div>
<div id="footer">
<div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/r18/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" /></a></div>
<ul>
<li>© 1999-2008 Spatial Corp.</li>
<li> Please send feedback to <a href="mailto:docfeedback_spatial@3ds.com">docfeedback_spatial@3ds.com</a> or just <a href="../index.php?title=Special:Userlogin&returnto=Special:Userlogout">login</a> and start editing the comments page.</li>
</ul>
<ul id="f-list">
<li id="lastmod"> This page was last modified 15:59, 23 May 2008.</li>
<li id="viewcount">This page has been accessed 28 times.</li>
<li> <a href="../index.php/Project:Terms_of_Use">Terms of Use</a> </li>
<li> <a href="../index.php/Project:Privacy_policy">Privacy Policy</a> </li>
</ul>
</div>
<script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script> <script type='text/javascript' src='/r18/javascript_form/getXterlinks.js'></script> <script type='text/javascript'>getXterlinks()</script></div>
<!-- Served in 0.206 secs. --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -