C++ÓëCµÄÇø±ð
±±º£
1£© º¯ÊýÉùÃ÷
l CÈç¹û²»Ð´·µ»ØÖµ£¬Ä¬ÈÏÊÇint£¬¶øC++Öв»Äܲ»Ð´·µ»ØÖµ(¿ÉÓÃvoid±íʾÎÞ·µ»ØÖµ)¡£
ÈçFunc1();
l int Func1()ÔÚCÖбíʾ¿É´øÈÎÒâ²ÎÊýµÄº¯Êý£¬ÕâÊÇCµÄ©¶´£¬Ê¹µÃËü±Ü¿ªÁ˲ÎÊýÀàÐͼì²é£»¶øC++Öбíʾ²»´ø²ÎÊýµÄº¯Êý¡£
2£© Í·ÎļþµÄÇø±ð
l C++µÄÍ·ÎļþÈ¥µôÁËCÖеÄ.h£¬ÒÔcǰ׺¿ªÊ¼¡£±ÈÈ磬<stdio.h> <stdlib.h>±äΪ<cstdio> <cstdlib>
l C´ø.hµÄÊÇ·ÇÄ£°å»¯µÄÍ·Îļþ£¬¶øC++ÊÇÄ£°å»¯µÄÍ·Îļþ¡£
.hÎļþÊDz»º¬ÃüÃû¿Õ¼äµÄ£¬ËùÒÔÒÔÇ°µÄ<iostream.h>ÊDz»ÐèÒªusingµÄ¡£
µ±È»Ò²¿ÉÒÔÓÃÀϵÄCÍ·Îļþ£¬µ«ÊÇ£¬ÔÚͬһ¸ö³ÌÐòÀï²»ÄÜ»ì×ÅÓã¬ËäÈ»±àÒë¿ÉÒÔͨ¹ý£¬µ«ÊÇ¿ÉÄÜ»á³öÏÖÎÊÌâ¡£
3£© register±äÁ¿
ÔÚCÓïÑÔÖУ¬ÊDz»ÄܶÔregister±äÁ¿È¡µØÖ·µÄ£¬ÒòΪËüûÓÐÐéµØÖ·£¬ÔڼĴæÆ÷Àï¡£¶øC++ÖУ¬ËüÊÇ¿ÉÒÔÈ¡Ö·µÄ£¬Õâʱ£¬C++±àÒëÆ÷»áºöÂÔregister£¬²»»á°ÑËü·Åµ½¼Ä´æÆ÷Àï¡£
4£© const±äÁ¿
CÖУ¬constÊÇÖ»¶ÁµÄ±äÁ¿£¬²»Êdz£Á¿£»C++ÖÐËüÊdz£Á¿¡£Çø±ðÓÃÀý×ÓÃèÊöÈçÏ£º
const int MAX = 10;
char buffer[MAX]; //CÖÐËüÊDz»ºÏ·¨µÄ£¬¿ÉÒÔÓÃenum»òdefineÌæ´ú£»
//C++ÖÐËüÊǺϷ¨µÄ¡£
±¾ÖÊ£ºCÖÐconst±äÁ¿·ÖÅäÔÚÈ«¾Ö¾²Ì¬Çø£»C++ÖÐÔòÔÚ³£Á¿Çø£¬±àÒë¹ý³ÌÖÐÖµ¾Í¶¨ÁË¡£
5£© typedef
ÔÚCÖУ¬
struct A
{
};
A a; //ÕâÊÇ´íÎóµÄ£¬ÔÚC++ÖÐÊǺϷ¨µÄ¡£
struct A a; //ÕâÊÇÕýÈ·µÄ
ÓÃÁËtypedefºó£¬CÖÐA a;Ò²ÊǺϷ¨µÄÁË¡£
6£© struct/union/class
l ¶ÔÓÚstruct/unionÊý¾Ý³ÉÔ±Ó뺯Êý³ÉÔ±µÄ·ÃÎÊÐÔÀ´Ëµ£¬ÆäĬÈÏÊÇpublic£»
l classÔòÊÇprivate¡£
l unionÁªºÏÌå²»ÄÜ×÷Ϊ»ùÀà¼Ì³Ð¡£
union A
{
};
class B: public A //±àÒë³ö´í
{
};
l ÄäÃûunion
union
{
int a;
float b;
};
ÔÚ³ÌÐòÀï¿ÉÒÔÖ±½Ó·ÃÎÊ
Ïà¹ØÎĵµ£º
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
class A{
public:
A(){
cout << "Ö´Ðй¹Ô캯Êý´´½¨Ò»¸ö¶ÔÏó" << endl;
}
A(A&){
cout << "Ö´Ðп½±´º¯Êý¿½±´Ò»¸ö¶ ......
ºÃ¾ÃÒÔÇ°×öµÄÒ»¸ö³ÌÐò£¬Ì°ÐIJßÂÔʵÏÖ±³°üÎÊÌ⣬cʵÏÖ¡£
×ܽáÔÚÕâÀÒÔ±¸ÒÔºóºÍ±ðÈ˲éÕÒ¡£
//±³°üÎÊÌâ
#include "stdio.h"
#define MAX 10
void main()
{
int w[MAX]={0,10,130,15,60,25}; //´æ·ÅÖÊÁ¿
int v[MAX]={0,30,5,10,20,25}; //´æ·Å¼ÛÖµ
flo ......
LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ
¡¡¡¡¸ÅÊö
¡¡¡¡¾ÍC£«£«¿ª·¢¹¤¾ß¶øÑÔ£¬ÓëWindowsÏÂ΢Èí£¨VC£¬ VS2005µÈ£©Ò»Í³ÌìÏÂÏà±È£¬Linux/UnixÏÂC£«£«¿ª·¢£¬¿ÉνÎ廨°ËÃÅ£¬¸÷ʽ¸÷Ñù¡£Emacs, vi, eclipse, anjuta£¬kdevelopµÈ²ã³ö²»Çî¡£
¡¡¡¡WindowsÏ£¬¿ª·¢¹¤¾ß¶àÒÔ¼¯³É¿ª·¢»·¾³IDEµÄÐÎʽչÏÖ¸ø×îÖÕÓû§¡£ÀýÈ磬VS2005¼¯³ ......
#include<stdio.h>
#define N 8
void input(int n,int p[N][N])
{
int i,j;
for(i=0;i<n;i++)
{
printf("please input the %d line:\n",i+1);
for(j=0;j<n;j++)
{
scanf("%d",&p[i][j]);
}
}
}
void output(int n,int p[N][N])
......
¡¶Cר¼Ò±à³Ì¡·Ñ§Ï°×ܽá2
ת×Ô £º http://blog.chinaunix.net/u2/87570/showart_2120069.html
±àÒëÆ÷×öÁËЩʲô
ͼ1£º±àÒëÆ÷ͨ³£·Ö¸î³É¼¸¸ö¸üСµÄ³ÌÐò
¾²Ì¬Á´½ÓÓ붯̬Á´½Ó
  ......