-pa贵宾会

���ݵĺ����뱣�� c �������ʺ��ڱ�д���͸��ӳ��������,���ݵĺ����뱣��������c ���ե� ��ҫ����֮һ�����½��ܱ�ʶ���������򡢿ɼ��ժ������ڵĸ���,�լ����ա�ĺ��� �뱣�����⡣�����ܳ���ķ��ļ��ṹ�ͱ���Ԥ��������,������ö��դ�����ļ� ����֯���ͳ��� 5.1 ��ʶ������������ɼ��� ���������۵��dz�ʶ������ч��χ,�ɼ��������۱�ʶ���ƿ���ա����á�����֪��, ��ij�������������ı�����ֻ�������������������,������ܱ�������������ɼ��ե� ���ơ���������ɼ��լ��໥��ϵ�ִ����źܴ���졣 5.1.1 ������ ��������һ����ʶ���ڳ�����������ч������c �����б�ʶ�����������к��� ԭ�������򡢾ֲ�������(��������)�����������ļ������������ռ���������޶������� ��enum ö���ࡣ 1.����ԭ�������� ����ԭ����������c ��������с�������򡣵�3���н��ܹ�,�ں���ԭ����һ��ҫ �����ͳε�����˵�����ں���ԭ������ʱ��ʽ���������÷�χ���ǻ���ԭ���������� ��,�����º�������: double area(double radius); ��ʶ��radius������(�����ч)��χ���ں���area�β��б�����������֮��,�ڳ��� �������ط��������������ʶ������˱�ʶ��radius���������������ԭ�������� ע�� �����ں���ԭ�͵��β��б��������õ�ֻ���β�����,��ʶ������������,�� ��������ʡȥ�ġ������ǵ�����ŀɶ���,ͨ������ҫ�ں���ԭ������ʱ�����βα� ʶ���� 2.�ֲ������� ϊ������ֲ�������,������һ�����ӡ� void fun(int a) { int b=a; cin>>b; if(b>0) { int c; �� } c �������� } } �� t y .... .... b �������� �� t y ..... ..... a �������� ����,�ں���fun���β��б����������β�a,�ں������������˱���b,����a��ֵ�� ʼ��b��������,��if�����,�������˱���c��a��b��c�����оֲ�������,ֻ�����ƿֱ� ���ڲ�ͬ�ľֲ������� �����β��б����βε�������,���β��б��е���������ʼ,���������������֮��ϊ ֹ�����,�β�a���������a����������ʼ,ֱ��fun�����ľ�����ϊֹ�������������� �ı���,�����������������ʼ,һֱ���������ڵŀ�����ļ�����ϊֹ����ν��,����һ �ի�������������һ�γ��������������,��������һ����,if���֮��ķ�֧������һ ����с�ŀ�,�����ǰ�����ϵ�����,����b�����������������ʼ,�������ڵŀ�(������ ������)������ϊֹ;������c�����������������ʼ,�������ڵŀ�,����֧�����ϊֹ�� ���оֲ�������ı���ҳ��ϊ�ֲ������� 3.�������� ����ա�������һ��������ա�ļ���,��x�ij�աm ������������,��m �ķ��ʷ�ʽ ������3�֡� (1)�����x �ij�ա������û������ͬ���ľֲ��������ʶ��,��ô�ڸú����ڿ��� ֱ�ӷ��ʳ�աm��ҳ����˵m �������ĺ����ж������á� (2)ͨ������ʽx.m ����x::m�������dz����з��ʶ����ա�������������x::m �ķ�ʽ���ڷ�����ľ�̬��ա,������ݽ���5.3�ڽ��ܡ� (3)ͨ��ptr->m �����ı���ʽ,����ptrϊָ��x ���һ�������ָ�롣����ָ�뽫 �ڵ�6����ϸ���ܡ� c ��,�༰���������������ķ��ʺ����������,�ں����½��л����������ۡ� 4.�ļ������� ����ǰ�������������г��ֵ�����,�;����ļ�������,���������ı�ʶ���������� ʼ��������,�������ļ�β����5-1����������ȫ�ֱ����;����ļ�������,������������ ���ж���ч�� 5.�����ռ������� �����д�����������,��c ӧ�ó�����,ҳ����ͬ��������������������,ϊ���� ������ͻ,ʹ�������ܹ��������բ�ͬ���ͬ��ʵ��,c �����������ռ�ĸ���,������ �϶�����ʵ�������ŀռ䡣�����ռ䶨��ʹ��namespace�ؼ���,������ʽ����: namespace namespace_name{ //�������� } ��5�� ���ݵĺ����뱣����151�� ʹ��ij�������ռ��еĺ�����������ʵ��,��ҫ�����ռ�� ʵ�����ƻ�ͨ��using namespacenamespace_name�ķ�ʽ����5-1��usingnamespacestdʹ�ñ�׼�����ռ��� ʵ���������ӿռ�ǰ׺,��my_space�е�funcͨ���˷�ʽ���á� 6.�޶��������enum ö���� �����ڵ�4�½�����enum ö����,ö�����ϊ�޶�������ͳ��޶�����������,���� ֮ǰδ�漰������ĸ���,��˵�4��ֻ���˲��޶������������,��������޶�������� enum ö������������������ۡ� �����޶��������ö�����͵ķ�ʽ��enumclass{...},������class��struct�޶���, ��ʱö��Ԫ�ص�������ѭ�����������׼��,����������,��ö�����͵����������dz��ɷ� �ʵġ��෴,�ڲ��޶��������ö��������,ö��Ԫ�ص���������ö�����ͱ����������� ��ͬ: enum color {red, yellow, green}; //���޶��������ö������ enum color1 {red, yellow, green}; //����,ö��Ԫ���ظ����� enum class color2 {red, yellow, green}; //��ȷ,�޶��������ö��Ԫ�ر������� color c=red; //��ȷ,color ��ö��Ԫ������ч���������� color2 c1=red; //����,color2 ��ö��Ԫ�ز�����ч���������� color c2=color::red; //��ȷ,������ʽ�ط���ö��Ԫ�� color2 c3=color2::red; //��ȷ,ʹ����color2 ��ö��Ԫ�� ��5-1 ������ʵ���� //5_1.cpp #include using namespace std; int i; //ȫ�ֱ���,�ļ������� int main() { i=5; //ϊȫ�ֱ���i ��ֵ { //�ӿ�1 int i; //�ֲ�����,�ֲ������� i=7; cout<<"i="< using namespace std; class clock { //ʱ���ඨ�� public: //�ⲿ�ӿ� clock(); void settime(int newh, int newm, int news); //3 ���βξ����к���ԭ�������� void showtime(); private: //˽�����ݳ�ա int hour, minute, second; }; //ʱ�����ա����ʵ�� clock::clock() : hour(0), minute(0), second(0) {} //���캯�� void clock::settime(int newh, int newm, int news) { //3 ���βξ����оֲ������� hour=newh; minute=newm; ��5�� ���ݵĺ����뱣����155�� second=news; } void clock::showtime() { cout< using namespace std; class point { //point �ඨ�� public: //�ⲿ�ӿ� point(int x=0, int y=0) : x(x), y(y) {//���캯�� //�ڹ��캯���ж�count �ۼ�,���ж���ͬά��ͬһ��count count ; } point(point &p) { //���ƹ��캯�� x=p.x; y=p.y; count ; } ~point() { count--;} int getx() {return x;} int gety() {return y;} void showcount() { //�����̬���ݳ�ա cout<<" object count="<
网站地图