#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
學習程式 發表在 痞客邦 留言(0) 人氣(102)
void f(int n,char a,char b ,char c) {
if(n==1){
printf("%d從%c移到%c\n",n,a,c);
}else{
f(n-1,a,c,b);
f(1,a,b,c);
f(n-1,b,a,c);
}
學習程式 發表在 痞客邦 留言(0) 人氣(28)
int &fun(int &a)
{
a += 10;
return a;
}
int main()
{
int a=10;
fun(a) = 5; ////方法回傳了a的address
cout << a;////5
return 0;
}
學習程式 發表在 痞客邦 留言(0) 人氣(29)

1.初始化列表:在宣告時就給變數預設值 class():variable(value){};
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class a{
public:
int c,d;
a():c(100) ,d(50){};
};
學習程式 發表在 痞客邦 留言(0) 人氣(423)
學習程式 發表在 痞客邦 留言(0) 人氣(17)