zoukankan      html  css  js  c++  java
  • 第一个C++

    输入:cin>>(相当于scanf)
     
    #include <iostream>
    using namespace std;
    int main()
    { int number;
     cout<<"hello!world!"<<endl; //printf "hello!world"
     cout<<"请输入数字:";
     cin>>number;   //输入数字
     cout<<"hello"<<number<<"lll"<<endl;  //输出hello+number里面的东西
     
     return 0;
    }
     
     
    面向对象:what is an object?
    object=entity
    #可见的(visible)
    对象就是变量(object is variable in programming languges)
     
    另一个角度:对象=结构;+服务(objects=attributes+services)
    from the problem space to the solution 
     
    C语言板的3d 图形效果
    typedef struct point3d
    {
    float x;
    float y;
    float z;
     
     
    } point3d;
     
    void point3d_printf(const Point3d*pd);
    point3d a;
    a.x=1;a.y=2;a.z=3;
    point3d_printf(&a);
     
     
     
    C++板的
    class point3d      //class=struct
    {
    public:
        Point3d(float x,float y,float z);
        print();   //调用print函数
    private:
        float x;
        float y;
        float z;   //私有数据
    };
     
    point3d a(1,2,3);
    a.print();     //a是一个对象    让a去做print函数功能
     
    区别:
    C语言的struct里不能做操作
    C++的类里面可以做数据的操作
     
     
    what  is object)-oriented  //导向
    1.it is a way 
    2.designs                    //设计  算法
    3.implementations   //实现  写代码
    4. object 主要用是设计与实现
     
     
     
     
    面向对象的基本原理
    object send messages
     
    messages are 
    -composed by the sender    //有发送z
    -interpreted by the receiver //服务器快来解读
    -implemented by methods   //y以函数的方式来传递
     
    messges 
        may cause receiver to change state
        may return results 
     
     
    object vs.class
    类是一个概念
    对象是一个实体
    {class define object 
    object is a class}
     
     
      object (cat)
        represent things events,or concepts
        respond to messages at run-time
     
    类定义了对象章什么样    
    对象是一个那样的东西
     
    oop characteristics
    1 everything is an obect .
    2 a program is a bouch of objects telling eachoather what to do by sending messages.
    3 each oject has its own memory made up of other objects.
    4 every object has a type .   //每一个对象都是一个类
    5 all object of a particular type can recieve the same messages .  //所有可以接受相同消息的对象可以被认为是同一个类
     
    an object has an interface 
    the  interface is the way it recevies messages.
    it is 
     
    functions of the interface //接口的功能
     
     
    caommunication   //用于通信  里面的东西和外界的通信 
     protection  // 接口可以保护里面的东西 
     
     
    the hidden implementation  //隐藏 封装的
     
    oop的三特性
    encapsulation   //封装  包装 
        bundle data and methods dealoing with thses data together in an object  //把数据和对数据的操作捆绑在一个对象里
        hide the details of the data the action   //里面的细节部分是隐藏的
         restrict(限制 约束) only access to the publicized  //只能看到公开的部分
    bun
    继承 
    多态性
     
     
     
    有年轻!有动力!有追逐!有发现!
  • 相关阅读:
    python 基础2.5 循环中continue与breake用法
    python 基础 2.4 while 循环
    python 基础 2.3 for 循环
    python 基础 2.2 if流程控制(二)
    python 基础 2.1 if 流程控制(一)
    python 基础 1.6 python 帮助信息及数据类型间相互转换
    python 基础 1.5 python数据类型(四)--字典常用方法示例
    Tornado Web 框架
    LinkCode 第k个排列
    LeetCode 46. Permutations
  • 原文地址:https://www.cnblogs.com/da-guang/p/4140628.html
Copyright © 2011-2022 走看看