1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉
標題:
c++筆記 創建頭文件(不帶形參)
[打印本頁]
作者:
51黑fan
時間:
2016-1-31 03:34
標題:
c++筆記 創建頭文件(不帶形參)
創建頭文件。(不帶形參)
cpp通過類名+::+函數名被頭文件鏈接。注意一定是類名+::!
函數代碼放在cpp下的相應的函數名里,而頭文件中的只是函數名,只負責提供映射。
animal.cpp
#include "animal.h"
#include <iostream.h>
animal::animal()
{
cout<<"hello"<<endl;
}
void animal::eat ()
{
cout<<"shift"<<endl;
}
animal.h
//頭文件只寫函數名,提供鏈接地址。
#ifndef ANIMAL_H_H
#define ANIMAL_H_H
class animal
{
public:
animal();
void eat();
};
#endif
作者:
51黑fan
時間:
2016-1-31 03:35
c++ 03 創建頭文件前的準備 01
#include<iostream.h>
class animal
{
public:
animal()
{
cout<<"animal construct"<<endl;
}
~animal()
{
cout<<"construct animal"<<endl;
}
virtual void breath()
{
cout<<"bubble2"<<endl;
}
void eat();//把主函數放在類外的方法
};
class fish:public animal
{
public:
fish()
{
}
~fish()
}
void breath()
{
}
};
void animal::eat()//函數類型,屬于那個類。把一個函數的實現放到類之外。
{
}
void main()
{
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1