MVP+RxJava+Retrofit+Fresco+屏幕适配

依赖包
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

compile 'io.reactivex:rxjava:1.0.14'
compile 'io.reactivex:rxandroid:1.0.1'

compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.facebook.fresco:fresco:1.5.0'

compile 'com.jcodecraeer:xrecyclerview:1.3.2'

compile 'com.zhy:autolayout:1.4.5'
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.bwie.qiaoxiaohui20171209.view.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:text="新品"/>
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:gravity="center">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:textColor="@color/colorAccent"
            android:text="o精选新品"/>
    </RelativeLayout>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>
xrv_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/liear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="5dp"
    android:orientation="vertical">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/sdv"
        android:layout_width="match_parent"
        android:layout_height="300px"
        app:placeholderImage="@mipmap/ic_launcher_round"/>
    <TextView
        android:id="@+id/tv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"/>
    <TextView
        android:id="@+id/tv2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorAccent"/>
</LinearLayout>
activity_particulars.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.bwie.qiaoxiaohui20171209.view.ParticularsActivity">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/p_sdv"
        android:layout_width="match_parent"
        android:layout_height="300px" />
    <TextView
        android:id="@+id/p_tv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:textSize="20sp"
        android:textColor="@color/colorAccent"/>
    <TextView
        android:id="@+id/p_tv2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:layout_marginTop="5dp"/>
    <TextView
        android:id="@+id/p_tv3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp">
            <TextView
                android:id="@+id/pj"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="商品评价"/>
            <TextView
                android:id="@+id/ck"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="查看全部"/>
        </RelativeLayout>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/p_rv1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="店铺推荐"/>
        </RelativeLayout>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/p_rv2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="5dp"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="商品详情"
            android:layout_margin="10dp"/>

        <TextView
            android:id="@+id/p_tv4"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
rv_item0.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/liear"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="5dp">

        <TextView
            android:id="@+id/tv_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp" />

        <TextView
            android:id="@+id/tv_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp" />

        <TextView
            android:id="@+id/tv_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:textColor="@color/colorAccent" />
    </LinearLayout>
</ScrollView>
rv_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/liear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="5dp"
    android:orientation="vertical">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/rsdv"
        android:layout_width="match_parent"
        android:layout_height="300px"
        app:placeholderImage="@mipmap/ic_launcher_round"/>
    <TextView
        android:id="@+id/rtv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"/>
    <TextView
        android:id="@+id/rtv2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorAccent"/>
</LinearLayout>
MyApp--初始化Fresco,加载图片
public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Fresco.initialize(this);
    }
}
Api--数据接口
public class Api {
    public static final String HOST1 = "http://apiv3.yangkeduo.com/";
    public static final String HOST2 = "http://apiv4.yangkeduo.com/";
    public static final String NWESLIST = "v5/newlist?page=1&size=20&ver=1512745500001&pdduid=3470667255";//新品列表
    public static final String PARTICULARS = "v5/goods/202517471?pdduid=3470667255";//产品详情页面接口
    public static final String RECOMMEND = "recommendation/mall?{goods_id}?&pdduid=3470667255";//店铺推荐接口
    public static final String COMMENTARIES = "reviews/{gid}?page=1&size=2&label=1&is_back=1&pdduid=3470667255";//产品评论接口
}
OnNetListener--成功、失败回调接口
public interface OnNetListener<T> {
    public void onSuccess(T t);
    public void onFailure(Exception e);
}
ServerApi--RetrofitHelper的接口
public interface ServerApi {
    @GET(Api.NWESLIST)
    Observable<NewsList> newslist();
    @POST("v5/goods/{gid}?pdduid=3470667255")
    Observable<Particulars> particulars(@Path("gid") String id);
    @POST("recommendation/{mall}?pdduid=3470667255&")
    Observable<Recommend> recommend(@Path("mall") String mall,@Query("goods_id") String id);
    @GET(Api.COMMENTARIES)
    Observable<Commentaries> commentaries(@Path("gid") String id);
}
RetrofitHelper--网络请求封装
public class RetrofitHelper {
    private static OkHttpClient client;
    private static ServerApi serverApi;
    static {
        getClient();
    }

    public static OkHttpClient getClient() {
        if (client == null){
            synchronized (OkHttpClient.class){
                if (client == null){
                    client = new OkHttpClient();
                }
            }
        }
        return client;
    }

    public static ServerApi getServerApi1() {
        if (serverApi == null){
            synchronized (ServerApi.class){
                if (serverApi == null){
                    serverApi = onCreate(ServerApi.class,Api.HOST1);
                }
            }
        }
        return serverApi;
    }
    public static ServerApi getServerApi() {
        if (serverApi == null){
            synchronized (ServerApi.class){
                if (serverApi == null){
                    serverApi = onCreate(ServerApi.class,Api.HOST2);
                }
            }
        }
        return serverApi;
    }
    public static <T> T onCreate(Class<T> tClass,String url){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit.create(tClass);
    }
}
model层的接口--Main的接口-展示新品
public interface IMainModel {
    public void getNewsList(OnNetListener<NewsList> onNetListener);
}
model层--Main的类
public class MainModel implements IMainModel {
    public void getNewsList(final OnNetListener<NewsList> onNetListener){
        ServerApi serverApi1 = RetrofitHelper.getServerApi1();
        serverApi1.newslist()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<NewsList>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        onNetListener.onFailure((Exception) e);
                    }

                    @Override
                    public void onNext(NewsList newsList) {
                        onNetListener.onSuccess(newsList);
                    }
                });
    }
}
presenter层--MainActivity和MainModel的交互层
public class MainPresenter {
    private IMainModel iMainModel;
    private IMainActivity iMainActivity;

    public MainPresenter(IMainActivity iMainActivity) {
        this.iMainActivity = iMainActivity;
        iMainModel = new MainModel();
    }
    public void setNewsList(){
        iMainModel.getNewsList(new OnNetListener<NewsList>() {
            @Override
            public void onSuccess(NewsList newsList) {
                iMainActivity.showNewsList(newsList);
            }

            @Override
            public void onFailure(Exception e) {

            }
        });
    }
}
view层的MainActivity的接口
public interface IMainActivity {
    public void showNewsList(NewsList newsList);
}
view层的MainActivity类
public class MainActivity extends AppCompatActivity implements IMainActivity {

    private RecyclerView rv;
    private MainPresenter mainPresenter = new MainPresenter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        mainPresenter.setNewsList();
        rv.setLayoutManager(new GridLayoutManager(this,2));
    }

    private void initView() {
        rv = findViewById(R.id.rv);
    }

    @Override
    public void showNewsList(NewsList newsList) {
        final List<NewsList.GoodsListBean> list = newsList.getGoods_list();
        RvAdapter adapter = new RvAdapter(this, list);
        rv.setAdapter(adapter);
        adapter.setOnClickItemListener(new RvAdapter.OnClickListener() {
            @Override
            public void OnClickItemListener(int position) {
                Toast.makeText(MainActivity.this,"点击了"+position,Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this, ParticularsActivity.class);
                int id = list.get(position).getGoods_id();
                intent.putExtra("id",id+"");
                startActivity(intent);
            }
        });
    }
}
MainActivity的Recycler的适配器
public class RvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<NewsList.GoodsListBean> lists;

    public RvAdapter(Context context, List<NewsList.GoodsListBean> lists) {
        this.context = context;
        this.lists = lists;
    }
    //为点击事件设置自定义接口
    public OnClickListener onClickItemListener;

    public interface OnClickListener {
        public void OnClickItemListener(int position);
    }

    public void setOnClickItemListener(OnClickListener onClickItemListener) {
        this.onClickItemListener = onClickItemListener;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.xrv_item, null);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        MyViewHolder holder1 = (MyViewHolder) holder;
        final NewsList.GoodsListBean bean = lists.get(position);
        holder1.sdv.setImageURI(bean.getImage_url());
        holder1.tv1.setText(bean.getShort_name());
        holder1.tv2.setText("¥"+bean.getNormal_price());
        holder1.linear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onClickItemListener.OnClickItemListener(position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return lists.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        LinearLayout linear;
        SimpleDraweeView sdv;
        TextView tv1;
        TextView tv2;
        public MyViewHolder(View itemView) {
            super(itemView);
            linear = itemView.findViewById(R.id.liear);
            sdv = itemView.findViewById(R.id.sdv);
            tv1 = itemView.findViewById(R.id.tv1);
            tv2 = itemView.findViewById(R.id.tv2);
        }
    }
}
model层的Particulars的接口--商品详情、商品评价、店铺推荐
public interface IParticularsModel {
    public void getParticulars(OnNetListener<Particulars> onNetListener,String id);
    public void getCommentaries(OnNetListener<Commentaries> onNetListener,String id);
    public void getRecommend(OnNetListener<Recommend> onNetListener, String mall, String id);
}
model层的Particulars类--实现IParticularsModel接口
public class ParticularsModel implements IParticularsModel{
    public void getParticulars(final OnNetListener<Particulars> onNetListener,String id){
        ServerApi serverApi = RetrofitHelper.getServerApi();
        serverApi.particulars(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<Particulars>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        onNetListener.onFailure((Exception) e);
                    }

                    @Override
                    public void onNext(Particulars particulars) {
                        onNetListener.onSuccess(particulars);
                    }
                });
    }

    @Override
    public void getCommentaries(final OnNetListener<Commentaries> onNetListener, String id) {
        ServerApi serverApi = RetrofitHelper.getServerApi();
        serverApi.commentaries(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<Commentaries>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        onNetListener.onFailure((Exception) e);
                    }

                    @Override
                    public void onNext(Commentaries commentaries) {
                        onNetListener.onSuccess(commentaries);
                    }
                });
    }

    @Override
    public void getRecommend(final OnNetListener<Recommend> onNetListener, String mall, String id) {
        ServerApi serverApi = RetrofitHelper.getServerApi();
        serverApi.recommend(mall,id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<Recommend>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        onNetListener.onFailure((Exception) e);
                    }

                    @Override
                    public void onNext(Recommend recommend) {
                        onNetListener.onSuccess(recommend);
                    }
                });
    }
}
presenter层的Particulars类--实现IParticularsModel和ParticularsActivity的交互
public class ParticularsPresenter {
    private IParticularsModel iParticularsModel;
    private IParticularsActivity iParticularsActivity;

    public ParticularsPresenter(IParticularsActivity iParticularsActivity) {
        this.iParticularsActivity = iParticularsActivity;
        iParticularsModel = new ParticularsModel();
    }

    public void setParticulars(String id){
        iParticularsModel.getParticulars(new OnNetListener<Particulars>() {
            @Override
            public void onSuccess(Particulars particulars) {
                iParticularsActivity.showParticulars(particulars);
            }

            @Override
            public void onFailure(Exception e) {

            }
        },id);
    }
    public void setCommentaries(String id){
        iParticularsModel.getCommentaries(new OnNetListener<Commentaries>() {
            @Override
            public void onSuccess(Commentaries commentaries) {
                iParticularsActivity.showCommentaries(commentaries);
            }

            @Override
            public void onFailure(Exception e) {

            }
        },id);
    }
    public void setRecommend(String mall,String id){
        iParticularsModel.getRecommend(new OnNetListener<Recommend>() {
            @Override
            public void onSuccess(Recommend recommend) {
                iParticularsActivity.showRecommend(recommend);
            }

            @Override
            public void onFailure(Exception e) {

            }
        },mall,id);
    }
}
view层的Particulars的Activity接口
public interface IParticularsActivity {
    public void showParticulars(Particulars particulars);
    public void showCommentaries(Commentaries commentaries);
    public void showRecommend(Recommend recommend);
}
view层的ParticularsActivity
public class ParticularsActivity extends AppCompatActivity implements IParticularsActivity {

    private SimpleDraweeView mPSdv;
    private TextView mPTv1;
    private TextView mPTv2;
    private TextView mPTv3;
    /**
     * 商品评价
     */
    private TextView mPj;
    /**
     * 查看全部
     */
    private TextView mCk;
    private RecyclerView mPRv1;
    private RecyclerView mPRv2;
    private TextView mPTv4;
    private ParticularsPresenter particularsPresenter = new ParticularsPresenter(this);
    private String id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_particulars);
        initView();
        id = getIntent().getStringExtra("id");
        particularsPresenter.setParticulars(id);
        particularsPresenter.setRecommend("mall",id);
        particularsPresenter.setCommentaries(id);
        mPRv1.setLayoutManager(new LinearLayoutManager(this));
        mPRv2.setLayoutManager(new GridLayoutManager(this,3));
    }

    private void initView() {
        mPSdv = findViewById(R.id.p_sdv);
        mPTv1 = findViewById(R.id.p_tv1);
        mPTv2 = findViewById(R.id.p_tv2);
        mPTv3 = findViewById(R.id.p_tv3);
        mPj = findViewById(R.id.pj);
        mCk = findViewById(R.id.ck);
        mPRv1 = findViewById(R.id.p_rv1);
        mPRv2 = findViewById(R.id.p_rv2);
        mPTv4 = findViewById(R.id.p_tv4);
    }

    @Override
    public void showParticulars(Particulars particulars) {
        mPSdv.setImageURI(particulars.getGallery().get(0).getUrl());
        mPTv1.setText("¥"+particulars.getMarket_price());
        mPTv2.setText(particulars.getGoods_name());
        List<Particulars.ServicePromiseBean> list1 = particulars.getService_promise();
        mPTv3.setText(list1.get(0).getType()+"      "+list1.get(1).getType()+"      "+list1.get(2).getType()+"      "+list1.get(3).getType());
        mPTv4.setText(particulars.getGoods_name()+"/n"+particulars.getShare_desc());
    }

    @Override
    public void showCommentaries(Commentaries commentaries) {
        mPRv1.setAdapter(new Rv1Adapter(this,commentaries.getData()));
    }

    @Override
    public void showRecommend(Recommend recommend) {
        mPRv2.setAdapter(new Rv2Adapter(this,recommend.getList()));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        finish();
    }
}
商品评价适配器
public class Rv1Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<Commentaries.DataBean> list;

    public Rv1Adapter(Context context, List<Commentaries.DataBean> list) {
        this.context = context;
        this.list = list;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.rv_item0, null);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyViewHolder holder1 = (MyViewHolder) holder;
        Commentaries.DataBean dataBean = list.get(position);
        holder1.tv1.setText(dataBean.getComment());
        holder1.tv2.setText(dataBean.getSpecs());
        holder1.tv3.setText("**名称:"+dataBean.getName());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        TextView tv1;
        TextView tv2;
        TextView tv3;
        public MyViewHolder(View itemView) {
            super(itemView);
            tv1 = itemView.findViewById(R.id.tv_1);
            tv2 = itemView.findViewById(R.id.tv_2);
            tv3 = itemView.findViewById(R.id.tv_3);
        }
    }
}
店铺推荐适配器
public class Rv2Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<Recommend.ListBean> lists;

    public Rv2Adapter(Context context, List<Recommend.ListBean> lists) {
        this.context = context;
        this.lists = lists;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.rv_item, null);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        MyViewHolder holder1 = (MyViewHolder) holder;
        Recommend.ListBean listBean = lists.get(position);
        holder1.sdv.setImageURI(listBean.getHd_thumb_url());
        holder1.tv1.setText(listBean.getShort_name());
        holder1.tv2.setText("¥"+listBean.getPrice());
    }

    @Override
    public int getItemCount() {
        return lists.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        SimpleDraweeView sdv;
        TextView tv1;
        TextView tv2;
        public MyViewHolder(View itemView) {
            super(itemView);
            sdv = itemView.findViewById(R.id.rsdv);
            tv1 = itemView.findViewById(R.id.rtv1);
            tv2 = itemView.findViewById(R.id.rtv2);
        }
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于C++&OPENCV 的全景图像拼接 C++是一种广泛使用的编程语言,它是由Bjarne Stroustrup于1979年在新泽西州美利山贝尔实验室开始设计开发的。C++是C语言的扩展,旨在提供更强大的编程能力,包括面向对象编程和泛型编程的支持。C++支持数据封装、继承和多态等面向对象编程的特性和泛型编程的模板,以及丰富的标准库,提供了大量的数据结构和算法,极大地提高了开发效率。12 C++是一种静态类型的、编译式的、通用的、大小写敏感的编程语言,它综合了高级语言和低级语言的特点。C++的语法与C语言非常相似,但增加了许多面向对象编程的特性,如类、对象、封装、继承和多态等。这使得C++既保持了C语言的低级特性,如直接访问硬件的能力,又提供了高级语言的特性,如数据封装和代码重用。13 C++的应用领域非常广泛,包括但不限于教育、系统开发、游戏开发、嵌入式系统、工业和商业应用、科研和高性能计算等领域。在教育领域,C++因其结构化和面向对象的特性,常被选为计算机科学和工程专业的入门编程语言。在系统开发领域,C++因其高效性和灵活性,经常被作为开发语言。游戏开发领域中,C++由于其高效性和广泛应用,在开发高性能游戏和游戏引擎中扮演着重要角色。在嵌入式系统领域,C++的高效和灵活性使其成为理想选择。此外,C++还广泛应用于桌面应用、Web浏览器、操作系统、编译器、媒体应用程序、数据库引擎、医疗工程和机器人等领域。16 学习C++的关键是理解其核心概念和编程风格,而不是过于深入技术细节。C++支持多种编程风格,每种风格都能有效地保证运行时间效率和空间效率。因此,无论是初学者还是经验丰富的程序员,都可以通过C++来设计和实现新系统或维护旧系统。3

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值