之前工作需要研究一下libraries,所以找了一些資料,
發現這個網站講的蠻不錯的,
想要了解Library的可以參考一下,
Building And Using Static And Shared "C" Libraries
還有一些其他的Tutorials也不錯唷:)

iceis 發表在 痞客邦 留言(0) 人氣()

refer to What is the difference between malloc and calloc functions?
簡單的說,
calloc(m, n);
就等於

iceis 發表在 痞客邦 留言(0) 人氣()

refer to http://www.cppreference.com/stdother/exit.html
Syntax:
#include
void exit( int exit_code );

The exit() function stops the program.
exit_code is passed on to be the return value of the program,
where usually zero indicates success and non-zero indicates an error.

iceis 發表在 痞客邦 留言(0) 人氣()

refer to the article http://www.ozzu.com/ftopic1910.html
void rev(char* s)
{
int inner, outer= strlen(s)-1; // 原文誤植為2
char temp;

iceis 發表在 痞客邦 留言(0) 人氣()

Thinking in C++ 2nd Edition by Bruce Eckel
Free Electronic Book
Volume 1 & Volume 2
Download from Here!

iceis 發表在 痞客邦 留言(0) 人氣()

=====================
#include
#include
using namespace std;
class Pet {
public:
    virtual string speak() const { return "Pet!"; }
};
class Dog : public Pet {
public:
  string speak() const { return "Bark!"; }
};
class Cat : public Pet {
public:
  string speak() const { return "Miao!"; }
};
void doSpeak(Pet &animal){
    cout << animal.speak() << endl;
}
int main() {
    Dog dog;
    Cat cat;
    Pet pet;
    
    //Late binding for both:
    doSpeak(dog);
    doSpeak(cat);
    doSpeak(pet);
    return 0;
}
==================
output結果:
Bark!
Miao!
Pet!
==================
若Pet中的speak( ) 不宣告為virtual,則output:
Pet!
Pet!
Pet!
==================
Dog跟Cat是繼承自Pet這個base class,
經由virtual的宣告,可以在doSpeak中藉由傳進來的類別(Dog or Cat)判斷要做誰的doSpeak();
若Dog或Cat中,不去override speak這個function,當然都會output: Pet!
若將Pet中的speak() 改寫成virtual string speak() const  = 0;
( = 0是pure virtual funcion的關鍵字)
則該virtual function會變成pure virtual function,
進而讓Pet這個class變成abstract class,
在程式中宣告任何Pet的Instance都會造成compile error,
一定要有derived class才能去宣告該class的instance。

iceis 發表在 痞客邦 留言(0) 人氣()

[ By Tonnny @ ptt]
// 如此可產生n*m的array.....
// n,m可由使用者輸入!
// 重點是,此array可以在functions內使用
#include

void main(){
int n;
int m;
cin >> n >> m;
int **a=(int **)new int*[n];
for (int i = 0; i < n; i++)
{
*a(m+i)=(int *)new int[i][m];
}
for (int k = 0; k < n; k++){
for (int j = 0;j < m; j++)
{
a[k][j] = 0;
}
}
for (i = 0; i < n; i++)
{
delete [] a[i];
}
delete [] a;
}

iceis 發表在 痞客邦 留言(0) 人氣()

http://ehome.hifly.to/showthread.php?s=&threadid=889
goto到底該不該用?
基於在論壇上走動的大半是學生,所以通常我不太對這問題發表個人意見,
以免影響學生成績。
最近看到一論壇又有多篇有關 goto 指令該不該(或可不可用)用的討論。

iceis 發表在 痞客邦 留言(0) 人氣()

in C : #include
in C++ : #include
ps.C++中include c的library header file,可直接寫且不需副檔名
c++中 include 需加using namespace
如果是include 等原本是c的lib則不用

iceis 發表在 痞客邦 留言(0) 人氣()

C/C++ Programming interview questions and answers

iceis 發表在 痞客邦 留言(0) 人氣()

http://www.mblog.com/sanjayvyas/038185.html
一篇關於在四種Language寫Swap function很好的討論文章...:)
Java:
public class SwapApp
{

iceis 發表在 痞客邦 留言(2) 人氣()

[By JHF 學長]
while(1)
{
if (kbhit())
{

iceis 發表在 痞客邦 留言(0) 人氣()

1 2
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。