C++ Data Structure 1
来源:互联网 发布:淘宝网男装 编辑:程序博客网 时间:2024/05/23 14:55
Learn Data Structure by C++
1.Define *.h file
/* hello.h*/
#include <iostream>
class Hello
{
public:
void sayHello(const char *str);
};
*
2.Define an public function of class Hello
/* hello.h*/
#include <iostream>
class Hello
{
public:
void sayHello(const char *str);
};
*
3.Using an main function
/* main.cpp
Will you compile it using g++ hello.cpp main.cpp -o hello
*/
#include "hello.h"
int main(int argc,char *argv[])
{
Hello hello;
hello.sayHello("World...");
return 0;
}
4.Compile it with g++ hello.cpp main.cpp -o hello
*5.Another example:
/* rectangle.h
*/
#ifndef __RECTANGLE_H__
#define __RECTANGLE_H__
class Rectangle
{
private:
int length,width,height;
public:
Rectangle(int len,int wd,int ht);
virtual~Rectangle(void){}
int Volume(void);
};
#endif
*
/* rectangle.cpp
*/
#include "rectangle.h"
Rectangle::Rectangle(int len,int wd,int ht)
{
length =len;
width =wd;
height =ht;
}
int Rectangle::Volume(void)
{
return length*width*height;
}
*/* main1.cpp
*/
#include <stdlib.h>
#include <iostream>
using namespace std;
#include "rectangle.h"
int main(int argc,char *arg[])
{
Rectangle thisRectangle(6,8,9);
int volume = thisRectangle.Volume();
cout<<"The Volume of that Rectangle was:_"<<volume<<endl;
system("PAUSE");
return 0;
}
***Learn it setp by step...
- Data Structure(1)
- C++ Data Structure 1
- Data Structure(1)---线性表
- Data Structure(with C).Experiment01.01
- Data Structure(with C).Experiment01.02
- Data Structure
- Data structure
- Data Structure
- Data structure
- Data structure
- data structure
- Data Structure
- Data structure
- Data Structure
- Data Structure
- Data Structure
- Data Structure
- Perl implement Tree data structure (1)
- 【ios 基础知识】之 常用字符串的操作
- Android-Button控件基础
- myeclipse的一些使用技巧
- Linux ALSA声卡驱动之四:Control设备的创建
- hive数据倾斜总结
- C++ Data Structure 1
- 静态构造函数只在静态字段初始化后执行一次。。。/另附 装箱问题
- 选择、插入、冒泡排序
- 自动提示
- G家
- java输出问题
- 很开心收到了Andreas Loew发给我的注册key
- nil , Nil , NULL, [NSNull null] , @"" 详解
- java uuid 随机生成唯一序列号