C++基础-数据类型

本文主要讲述C++基本数据类型,如何引用这些基本数据类型.

1.在data.h中声明

//data.h文件
#include "stdio.h"
#include <string>
#in !undefined(AFX_123)

int age;
short height;
long distance;

float weight;
double area;

char  c;
char* p;
char radio[10]={"hello C++"};

bool result;

#define AFX_123
#endif

2. 在data.cpp中定义和引用

#include "data.h"
#include "iostream.h"

void main()
{
//开始定义
age=10;
height=175;
distance=3;

weight=145.1;
area=7.5211;

c='D';
p=radio;

cout<<"age="<<age<<endl;
cout<<"height="<<height<<endl;
cout<<"distance="<<distance<<endl;
cout<<"weight="<<weight<<endl;
cout<<"area="<<area<<endl;
cout<<"字符c="<<c<<endl;
cout<<"数组radio"<<radio<<endl;
cout<<"指针数据"<<p<<endl; }

 

posted @ 2013-01-03 07:30  血洗女生宿舍  阅读(102)  评论(0编辑  收藏  举报