﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-SEMAN-文章分类-C/C++ BASIC</title><link>http://www.cppblog.com/SEMAN/category/389.html</link><description>曾经沧海难为水、除却巫山不是云</description><language>zh-cn</language><lastBuildDate>Fri, 23 May 2008 07:09:10 GMT</lastBuildDate><pubDate>Fri, 23 May 2008 07:09:10 GMT</pubDate><ttl>60</ttl><item><title>Good C++ Interview Questions</title><link>http://www.cppblog.com/SEMAN/articles/1343.html</link><dc:creator>味全每日C++</dc:creator><author>味全每日C++</author><pubDate>Sun, 27 Nov 2005 09:04:00 GMT</pubDate><guid>http://www.cppblog.com/SEMAN/articles/1343.html</guid><wfw:comment>http://www.cppblog.com/SEMAN/comments/1343.html</wfw:comment><comments>http://www.cppblog.com/SEMAN/articles/1343.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/SEMAN/comments/commentRss/1343.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/SEMAN/services/trackbacks/1343.html</trackback:ping><description><![CDATA[<H2><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>C++ Questions</FONT></H2>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the major differences between C and C++? </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the differences between <FONT color=#0000ff>new</FONT> and <FONT color=#0000ff>malloc</FONT>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the difference between <FONT color=#0000ff><CODE>delete</CODE> </FONT>and <CODE><FONT color=#0000ff>delete[]</FONT></CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the differences between a struct in C and in C++? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the advantages/disadvantages of using <CODE><FONT color=#0000ff>#define</FONT></CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the advantages/disadvantages of using <CODE><FONT color=#0000ff>inline</FONT></CODE> and <CODE><FONT color=#0000ff>const</FONT></CODE>? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the difference between a pointer and a reference? </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>When would you use a pointer? A reference? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What does it mean to take the address of a reference? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What does it mean to declare a function or variable as <CODE><FONT color=#0000ff>static</FONT></CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the order of initalization for data?</I> </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is name mangling/name decoration? </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What kind of problems does name mangling cause? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>How do you work around them? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is a class? </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the differences between a struct and a class in C++? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the difference between public, private, and protected access? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>For <CODE>class CFoo { };</CODE> what default methods will the compiler generate for you&gt;? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>How can you force the compiler to not generate them? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the purpose of a constructor? Destructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is a constructor initializer list? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>When <I>must</I> you use a constructor initializer list? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is a: </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Constructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Destructor?</I> </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Default constructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Copy constructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Conversion constructor? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What does it mean to declare a... </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>member function as <CODE>virtual</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>member function as <CODE>static</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>member function as <CODE>static</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>member variable as <CODE>static</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>destructor as <CODE>static</CODE>? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Can you explain the term "resource acquisition is initialization?" </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is a "pure virtual" member function? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the difference between public, private, and protected inheritance? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is virtual inheritance? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is placement <CODE>new</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is the difference between <CODE>operator new</CODE> and the <CODE>new</CODE> operator? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is exception handling? </FONT>
<UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>Explain what happens when an exception is thrown in C++. </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What happens if an exception is not caught? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What happens if an exception is throws from an object's constructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What happens if an exception is throws from an object's destructor? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What are the costs and benefits of using exceptions? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>When would you choose to return an error code rather than throw an exception? </FONT></LI></UL>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is a template? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is partial specialization or template specialization? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>How can you force instantiation of a template? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is an iterator? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is an algorithm (in terms of the STL/C++ standard library)? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is <CODE>std::auto_ptr</CODE>? </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>What is wrong with this statement? <CODE>std::auto_ptr<CHAR> ptr(new char[10]);</CODE> </FONT>
<LI><FONT style="BACKGROUND-COLOR: #ffffff" face=Verdana size=2>It is possible to build a C++ compiler on top of a C compiler. How would you do this? (Note: I've only asked this question once; and yes, he understood that I was asking him how cfront was put together. We hired him.) </FONT></LI></UL>
<P><FONT face=Verdana size=2>暂时发布问题，大家集思广益，争取把每个问题讨论的充分一点，我会在最快的时间给我出的答案：）</FONT></P><img src ="http://www.cppblog.com/SEMAN/aggbug/1343.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/SEMAN/" target="_blank">味全每日C++</a> 2005-11-27 17:04 <a href="http://www.cppblog.com/SEMAN/articles/1343.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>#pragma</title><link>http://www.cppblog.com/SEMAN/articles/1210.html</link><dc:creator>味全每日C++</dc:creator><author>味全每日C++</author><pubDate>Sun, 20 Nov 2005 16:40:00 GMT</pubDate><guid>http://www.cppblog.com/SEMAN/articles/1210.html</guid><wfw:comment>http://www.cppblog.com/SEMAN/comments/1210.html</wfw:comment><comments>http://www.cppblog.com/SEMAN/articles/1210.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/SEMAN/comments/commentRss/1210.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/SEMAN/services/trackbacks/1210.html</trackback:ping><description><![CDATA[<P><FONT face=Verdana size=2>在所有的预处理指令中，#Pragma 指令可能是最复杂的了，它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义,编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。<BR>其格式一般为: #Pragma Para<BR>其中Para 为参数，下面来看一些常用的参数。</FONT></P>
<P><FONT face=Verdana size=2>(1)message 参数。 Message 参数是我最喜欢的一个参数，它能够在编译信息输出窗<BR>口中输出相应的信息，这对于源代码信息的控制是非常重要的。其使用方法为：<BR>#Pragma message(“消息文本”)<BR>当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。<BR>当我们在程序中定义了许多宏来控制源代码版本的时候，我们自己有可能都会忘记有没有正确的设置这些宏，此时我们可以用这条指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏可以用下面的方法<BR>#ifdef _X86<BR>#Pragma message(“_X86 macro activated!”)<BR>#endif<BR>当我们定义了_X86这个宏以后，应用程序在编译时就会在编译输出窗口里显示“_<BR>X86 macro activated!”。我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了<BR>。</FONT></P>
<P><FONT face=Verdana size=2>(2)另一个使用得比较多的pragma参数是code_seg。格式如：<BR>#pragma code_seg( ["section-name"[,"section-class"] ] )<BR>它能够设置程序中函数代码存放的代码段，当我们开发驱动程序的时候就会使用到它。</FONT></P>
<P><FONT face=Verdana size=2>(3)#pragma once (比较常用）<BR>只要在头文件的最开始加入这条指令就能够保证头文件被编译一次，这条指令实际上在VC6中就已经有了，但是考虑到兼容性并没有太多的使用它。</FONT></P>
<P><FONT face=Verdana size=2>(4)#pragma hdrstop表示预编译头文件到此为止，后面的头文件不进行预编译。BCB可以预编译头文件以加快链接的速度，但如果所有头文件都进行预编译又可能占太多磁盘空间，所以使用这个选项排除一些头文件。 <BR>有时单元之间有依赖关系，比如单元A依赖单元B，所以单元B要先于单元A编译。你可以用#pragma startup指定编译优先级，如果使用了#pragma package(smart_init) ，BCB就会根据优先级的大小先后编译。 </FONT></P>
<P><FONT face=Verdana size=2>(5)#pragma resource "*.dfm"表示把*.dfm文件中的资源加入工程。*.dfm中包括窗体<BR>外观的定义。 </FONT></P>
<P><FONT face=Verdana size=2>(6)#pragma warning( disable : 4507 34; once : 4385; error : 164 )<BR>等价于：<BR>#pragma warning(disable:4507 34) // 不显示4507和34号警告信息<BR>#pragma warning(once:4385) // 4385号警告信息仅报告一次<BR>#pragma warning(error:164) // 把164号警告信息作为一个错误。<BR>同时这个pragma warning 也支持如下格式：<BR>#pragma warning( push [ ,n ] )<BR>#pragma warning( pop )<BR>这里n代表一个警告等级(1---4)。<BR>#pragma warning( push )保存所有警告信息的现有的警告状态。<BR>#pragma warning( push, n)保存所有警告信息的现有的警告状态，并且把全局警告<BR>等级设定为n。 <BR>#pragma warning( pop )向栈中弹出最后一个警告信息，在入栈和出栈之间所作的<BR>一切改动取消。例如：<BR>#pragma warning( push )<BR>#pragma warning( disable : 4705 )<BR>#pragma warning( disable : 4706 )<BR>#pragma warning( disable : 4707 )<BR>//.......<BR>#pragma warning( pop ) <BR>在这段代码的最后，重新保存所有的警告信息(包括4705，4706和4707)。<BR>（7）pragma comment(...)<BR>该指令将一个注释记录放入一个对象文件或可执行文件中。<BR>常用的lib关键字，可以帮我们连入一个库文件。</FONT></P><BR><img src ="http://www.cppblog.com/SEMAN/aggbug/1210.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/SEMAN/" target="_blank">味全每日C++</a> 2005-11-21 00:40 <a href="http://www.cppblog.com/SEMAN/articles/1210.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>