C++ÃæÊÔ¾µä
¾µäC++ÃæÊÔÌâ
1.½éÉÜÒ»ÏÂSTL£¬Ïêϸ˵Ã÷STLÈçºÎʵÏÖvector¡£
Answer:
STL (±ê׼ģ°æ¿â£¬Standard Template Library.ËüÓÉÈÝÆ÷Ëã·¨µü´úÆ÷×é³É¡£
STLÓÐÒÔϵÄһЩÓŵ㣺
¿ÉÒÔ·½±ãÈÝÒ×µØʵÏÖËÑË÷Êý¾Ý»ò¶ÔÊý¾ÝÅÅÐòµÈһϵÁеÄËã·¨£»
µ÷ÊÔ³ÌÐòʱ¸ü¼Ó°²È«ºÍ·½±ã£»
¼´Ê¹ÊÇÈËÃÇÓÃSTLÔÚUNIXƽ̨ÏÂдµÄ´úÂëÄãÒ²¿ÉÒÔºÜÈÝÒ×µØÀí½â£¨ÒòΪSTLÊÇ¿çƽ̨µÄ£©¡£
vectorʵÖÊÉϾÍÊÇÒ»¸ö¶¯Ì¬Êý×飬»á¸ù¾ÝÊý¾ÝµÄÔö¼Ó,¶¯Ì¬µÄÔö¼ÓÊý×é¿Õ¼ä¡£
2.Èç¹ûÓÃVC¿ª·¢³ÌÐò£¬³£¼ûÕâô¼¸¸ö´íÎó£¬C2001,c2005,c2011,ÕâЩ´íÎóµÄÔÒòÊÇʲô¡£
Answer:
¡¡¡¡ÔÚѧϰVC++µÄ¹ý³ÌÖУ¬Óöµ½µÄLNK2001´íÎóµÄ´íÎóÏûÏ¢Ö÷ҪΪ£º
¡¡¡¡unresolved external symbol “symbol”£¨²»È·¶¨µÄÍⲿ“·ûºÅ”£©¡£
¡¡¡¡Èç¹ûÁ¬½Ó³ÌÐò²»ÄÜÔÚËùÓеĿâºÍÄ¿±êÎļþÄÚÕÒµ½ËùÒýÓõĺ¯Êý¡¢±äÁ¿»ò±êÇ©£¬½«²úÉú´Ë´íÎóÏûÏ¢¡£
Ò»°ãÀ´Ëµ£¬·¢Éú´íÎóµÄÔÒòÓÐÁ½¸ö£ºÒ»ÊÇËùÒýÓõĺ¯Êý¡¢±äÁ¿²»´æÔÚ¡¢Æ´Ð´²»ÕýÈ·»òÕßʹÓôíÎó£»Æä´Î¿ÉÄÜʹÓÃÁ˲»Í¬°æ±¾µÄÁ¬½Ó¿â¡£
±à³ÌÖо³£ÄÜÓöµ½LNK2005´íÎó——Öظ´¶¨Òå´íÎó£¬ÆäʵLNK2005´íÎó²¢²»ÊÇÒ»¸öºÜÄѽâ¾öµÄ´íÎó.
3.¼Ì³ÐºÍίÅÉÓÐʲô·Ö±ð£¬ÔÚ¾ö¶¨Ê¹Óü̳лòÕßίÅɵÄʱºòÐèÒª¿¼ÂÇʲô¡£
ÔÚOOD,OOPÖУ¬×éºÏÓÅÓڼ̳Ð.
µ±È»¶à̬µÄ»ù´¡ÊǼ̳У¬Ã»Óм̳жà̬ÎÞ´Ó̸Æð¡£
µ±¶ÔÏóµÄÀàÐͲ»Ó°ÏìÀàÖк¯ÊýµÄÐÐΪʱ£¬¾ÍҪʹÓÃÄ£°åÀ´Éú³ÉÕâÑùÒ»×éÀà¡£
µ±¶ÔÏóµÄÀàÐÍÓ°ÏìÀàÖк¯ÊýµÄÐÐΪʱ£¬¾ÍҪʹÓü̳ÐÀ´µÃµ½ÕâÑùÒ»×éÀà.
4.Ö¸ÕëºÍÒýÓÃÓÐʲô·Ö±ð£»Èç¹û´«ÒýÓñȴ«Ö¸Õ밲ȫ£¬ÎªÊ²Ã´£¿Èç¹ûÎÒʹÓó£Á¿Ö¸ÕëÄѵÀ²»ÐÐÂð£¿
(1) ÒýÓÃÔÚ´´½¨µÄͬʱ±ØÐë³õʼ»¯£¬¼´ÒýÓõ½Ò»¸öÓÐЧµÄ¶ÔÏ󣻶øÖ¸ÕëÔÚ¶¨ÒåµÄʱºò²»±Ø³õʼ»¯£¬¿ÉÒÔÔÚ¶¨ÒåºóÃæµÄÈκεط½ÖØи³Öµ£®
(2) ²»´æÔڣΣգ̣ÌÒýÓã¬ÒýÓñØÐëÓëºÏ·¨µÄ´æ´¢µ¥Ôª¹ØÁª;¶øÖ¸ÕëÔò¿ÉÒÔÊÇNULL.
(3) ÒýÓÃÒ»µ©±»³õʼ»¯ÎªÖ¸ÏòÒ»¸ö¶ÔÏó£¬Ëü¾Í²»Äܱ»¸Ä±äΪÁíÒ»¸ö¶ÔÏóµÄÒýÓ㻶øÖ¸ÕëÔÚÈκÎʱºò¶¼¿ÉÒԸıäΪָÏòÁíÒ»¸ö¶ÔÏ󣮸øÒýÓø³Öµ²¢²»ÊǸıäËüºÍÔʼ¶ÔÏóµÄ°ó¶¨¹Øϵ£®
(4) ÒýÓõĴ´½¨ºÍÏú»Ù²¢²»»áµ÷ÓÃÀàµÄ¿½±´¹¹Ô캯Êý
(5) ÓïÑÔ²ãÃ棬ÒýÓõÄÓ÷¨ºÍ¶ÔÏóÒ»Ñù£»ÔÚ¶þ½øÖƲãÃ棬ÒýÓÃÒ»°ã¶¼ÊÇͨ¹ýÖ¸ÕëÀ´ÊµÏֵģ¬Ö»²»¹ý±àÒëÆ÷°ïÎÒÃÇÍê³ÉÁËת»».
²»´æÔÚ¿ÕÒýÓ㬲¢ÇÒÒýÓÃÒ»µ©±»³õʼ»¯ÎªÖ¸ÏòÒ»¸ö¶ÔÏó£¬Ëü¾Í²»Äܱ»¸Ä±äΪÁíÒ»¸ö¶ÔÏóµÄÒýÓã¬ÏԵúܰ²È«¡£
const Ö¸ÕëÈÔÈ»´æÔÚ¿ÕÖ¸Õ룬²¢ÇÒÓпÉÄܲúÉúÒ°Ö¸Õë.
×ܵÄÀ´Ëµ£ºÒýÓüȾßÓÐÖ¸ÕëµÄЧÂÊ£
Ïà¹ØÎĵµ£º
http://uncrustify.sourceforge.net/
Ident code, aligning on parens, assignments, etc
Align on '=' and variable definitions
Align structure initializers
Align #define stuff
Align backslash-newline stuff
Reformat comments (a little bit)
Fix inter-character spacing
Add or remove parens on return ......
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
void swap(int x, int y) {
cout << "x and y swap before : " << x << "\t" << y << endl;
int i = x;
x = y;
y = i; ......
C/C++ Reference
http://www.cppreference.com/
C++ Library Reference
http://www.cplusplus.com/ref/
Standard C++ Library Class Reference at Rogue Wave
http://www.roguewave.com/support/docs/hppdocs/stdref/
Dink ......
¸Õ¸Õ¿´µ½Ò»ÆªÎÄÕÂÌá³öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½£¬»ù±¾Òâ˼ÈçÏ£º
Çë¿´C++´úÂ룺
class Base
{
public:
Base()
{
init();
}
virtual ~Base() {}
protected:
int value;
virtual void init()
{
value = 100; &nb ......