第一章复习

// 通过这个小程序复习了一下 命名空间 、 const 、函数重载 、类的定义、类的两种实例化方式;
// 初步理解了C++ 特性的前提,把函数和类武装到牙齿,从 C面向过程 转变成 一门面向对象的语言;  
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int MAXN = 5;

namespace AA
{
    int x = 20;
    int y = 30;
}


class Aassd
{
public: 
    int x;
    void outx(){
        cout << x << endl;
    }
};

class Bassd
{
public:
    int x;
    int y;
    int arr[5];
    void outx(){
        cout << x << endl;
    }
    void outy(){
         cout << y << endl;
    }
    void outarr(){
        for( int i=0; i<MAXN; i++ ){
            cout <<  arr[i] << endl; 
        }
    }
};

int gax( float a,int b );
int gax( int a,int b,int c);
int gax( int a,int c );
int gax( float a,float b,double c,double d);

int main()
{
    Aassd coor;
    coor.x = 10 ;
    coor.outx();
    Bassd *coortwo = new Bassd();
    if( coortwo == NULL ){
        return 0;
    }
    coortwo->x = AA::x;
    coortwo->y = AA::y;
    coortwo->outx();
    coortwo->outy();
    for( int i=0; i<MAXN; i++ )
    {
        coortwo->arr[i] = i;
    }
    coortwo->outarr();
    delete coortwo;
    coortwo = NULL;
    gax(AA::x,AA::y);

    printf("\n");
    gax((float)AA::x,AA::y);
    printf("\n");
    float mid = AA::x*1.23; 
    gax(mid,AA::x,AA::y,AA::y);
    return 0;
} 

int gax( float a,int b )
{
    cout << "1 //" << a << " " << b << endl;
}
int gax( int a,int b,int c){
    cout << "2 //" << a << " " << b << " " << c << endl; 
}
int gax( int a,int c ){
    cout << "3 //" << a << " " << c << endl;
}
int gax( float a,float b,double c,double d){
    cout << "4 //" << a << " " << b <<" " << c << " " << d << endl;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值