博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++初识
阅读量:4695 次
发布时间:2019-06-09

本文共 1102 字,大约阅读时间需要 3 分钟。

C++全称:C Plus Plus   (.cpp)

     在C基础上扩充了:类与对象、多继承、命名空间、运算符重载、虚函数、异常处理、模版、、、

程序执行效率高,很多语言的底层都是用C、C ++实现的

     iostream :C++的输入输出库,类似于C的 stdio.h 

cin :istream类型的对象  ;  cout :ostream类型的对象。还有cerr 和clog 两个ostream类型的对象

endl:end line 换行

   /*   命名空间的概念(usingnamespace std)

        :: 作用域操作符

   */

#include <iostream>

using namespace std;   //提前使用命名空间

 

int main(int argc, const char * argv[]) {

    std::cout << "Hello World!" << std::endl;  //未提前使用命名空间时

    

    int num;

//    scanf("%d",&num);

//    printf("it's %d\n",num * 10);

    cin >> num ;

    cout << "it's " << num * 10 << endl;

    

    int age = 18;

    double height = 1.8;

    char name[12] = "huang";

//    printf(" My name is %s , age is %d , height is %f\n",name,age,height);

    cout << "My name is " << name << ", age is " << age << ", height is " << height << endl;

    

    /* endl  全称  end line */

    return 0;

}

结构体:可以增加成员函数

struct Student{

    int age;   //成员变量

    int num;

    char name[12];

    //成员函数

    void study(int a){

        cout << name << " age is " << age << " num is " << num << " , a is " << a << endl;

    }

};

 

int main(int argc, const char * argv[]) {

    Student s = {18,101,"Mack"};

    s.study(12);

 

转载于:https://www.cnblogs.com/Miracle-Huang/p/5587550.html

你可能感兴趣的文章
装饰器、迭代器、生成器
查看>>
对闭包的一点小认识
查看>>
HDOJ---1203 I NEED A OFFER![01背包问题]
查看>>
Reading List on Automated Program Repair
查看>>
element UI table组件后端排序
查看>>
20150117_js_设置时间的显示格式
查看>>
Python全栈开发之路 【第十六篇】:jQuey的动画效果、属性操作、文档操作、input的value...
查看>>
哈理工oj 1385-Leyni, LOLI and Toasts II解题报告-多重背包的二进制解法
查看>>
Unity资源 ----加载最好需要做哪些事
查看>>
【Codeforces 933A】A Twisty Movement
查看>>
【33.17%】【Codeforces 715A】Plus and Square Root
查看>>
【hihocoder 1519】 逃离迷宫II
查看>>
【Uva 10641】 Barisal Stadium
查看>>
xampp修改mysql默认密码详解
查看>>
import time 进度条动态输出26个字母
查看>>
JDK源码那些事儿之并发ConcurrentHashMap上篇
查看>>
【转】windows下安装Python虚拟环境virtualenvwrapper-win
查看>>
di'w第五次作业
查看>>
perl学习之路1
查看>>
wenbao与高斯消元
查看>>