1)第一个c++程序;


#include<iostream>  //input output stream
#include<string>
using namespace std; // 也可以使用using std::cout; //using std::cin; //using std::endl;表示要使用std中的cout 。语法 A::B要使用A中的B 。。“::"称为域操作符
int main()
{
        cout << "place input your name and your age:\n";
        string name;
        int age;
        cin >> name >> age;
        cout << name <<  " 你好,你出生于 " << 2013-age << "year"
                <<endl; //end line==>'\n'
//      return 0; //main函数中 有没有return 0 都无所谓! 编译时会自动的加上。



//名字空间表达方式有三种:   

//1.using namespace std ;  说明要使用的名字空间是sdt 
//2.//程序中用到哪个,就写那个

  using std::cout; 
  using std::cin; 
  using std::endl;
//3.用的时候再说明:

        std::cout << "place input your name and your age:\n";        

        std::cin >> name >> age;       

        std::cout << name <<  " 你好,你出生于 " << 2013-age << "year"                
<<

std::endl; //end line==>'\n'

//写使用自己的名字空间: 

#include<iostream>
using namespace std;
#include<string>
         
namespace lqf{
        string name = "liuqingfei";
}            
namespace lena{
        char name[20] = "lena"; 
        string image="image";
}   
using namespace lena; 
using namespace lqf;
int main()
{       
        cout << " I am " <<lqf:: name << endl;   // 有冲突(歧义)的地方特别说明 就行啦 就行啦 !
        return 0;
}   


//全局的那么 会被屏蔽  
//没有放在名字空间的中东西放在 匿名名字空间中  只用”::“ 表示  :  表示全局的,匿名的。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值