Chinaunix首页 | 论坛 | 博客
  • 博客访问: 368008
  • 博文数量: 715
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:46
文章分类

全部博文(715)

文章存档

2011年(1)

2008年(714)

我的朋友

分类:

2008-10-13 16:30:21

I summarize some case  which is declaration in C++, and other is defination as bellow

Declaration:
int foo(int,int); //function declaration

typedef short INT16; //typedef declaration

extern int var; //external declaration

class bar; // class declaration, you also use struct,union,enum

friend test; // friend declaration

using std::cout; // namespace declaration

Defination:
int y;

class foo {...};

struct bar {...};

foo* p;

static int i;

enum Color{RED,GREEN,BLUE};

const double PI = 3.1415;

union Rep{...};

void test(int p) {};

foo a;

bar b;

Declaration and Defination in a Class:
// A.h header file
// class A is a defination.
class A
{
public:
         int a;     // a is a defination
         static int b;       // b is a declaration, you will difine it outside this class
         int getValue();        // method getValue is a declaration., you will difine it outside this class
         // method getValue1 is a defination, it is an inline function.
         int getValue1()
         {
                  return a;
         }
};


--------------------next---------------------

阅读(155) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~