前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >云终端系列(一)—— 实时音视频Web端接入体验(Vue基础音视频通话篇)

云终端系列(一)—— 实时音视频Web端接入体验(Vue基础音视频通话篇)

原创
作者头像
楚歌
修改于 2020-11-22 18:24:26
修改于 2020-11-22 18:24:26
4.3K00
代码可运行
举报
运行总次数:0
代码可运行

这个系列呢,主要给各位观众老爷看看目前有较大趋势的SaaS应用的SDK在各种主流Web终端的使用姿势和异常分析,如果想要纯粹了解开发的或者云原生云开发的可以去往另一个系列——云开发系列。

引流链接:https://cloud.tencent.com/developer/article/1750264

今天给大家主要讲讲TRTC(Tencent RTC ,实时通讯),在4G时代下,直播,短视频,视频聊天等用手机看视频已经成为了如大家呼吸一般简单的事情。而5G时代的到来,虽然目前还并不知道5G下视频向产品的发展趋势,但总体而言,视频

这个目前也接入了云原生,如果后续有机会也给大家讲一讲传统RTC实现接入,和云原生接入的区别。

TRTC Web

在我的另一篇文章 https://cloud.tencent.com/developer/article/1738182中,详细展开了整个官方Web Demo 的架构,官方的Demo用的是jquery,但是大家懂得都懂,目前jquery在大多数情况下已经不再是开发中的首选了,目前更多的业务场景中是要如何把 trtc-js-sdk 接入到 vue,react 等框架内,这里的话给大家做一个参考实例,并且给大家总结一下注意要点,下面会贴一些核心的代码。

这一篇文章是讲Vue的,为什么叫初始篇呢,因为目前做了trtc的最基础的功能,未来也许会更多的案例(又给自己挖坑)

Vue

Vue 作为目前最为成熟的MVVM框架之一,相较于jquery去写,减少了大量视图上的操作,配合element-UI可以减少许多布局上的问题

先贴核心代码。

PS. Vue 这里有用到Router,所以会展示Router的用法,之后的React那边会展示非Router的思路

登录Login

代码语言:txt
AI代码解释
复制
<script>
// @ is an alias to /src
import TRTC from "trtc-js-sdk";
import axios from "axios";
import router from "../router";

export default {
  name: "Login",
  components: {},
  data() {
    return {
      //这里请填入对应的sdkAppId
      login: {
        sdkAppId_: 1400****221,
        userSig_: "",
        userId_: "",
        password_: "",
      },
      client_: null,
      isJoined_: false,
      isPublished_: false,
      isAudioMuted_: false,
      isVideoMuted_: false,
      localStream_: null,
      remoteStream_: null,
      members_: new Map(),
      mic: "",
      micOptions: [],
      camera: "",
      cameraOptions: [],
      
    };
  },
  created() {},
  mounted() {},
  methods: {
    async login_() {
      if (!(this.login.password_ && this.login.userId_)) {
        this.$alert("请确认用户名与密码已经填写", "注意!", {
          confirmButtonText: "确定",
          callback: (action) => {
            this.$message({
              type: "info",
              message: `action: ${action}`,
            });
          },
        });
      } else if (this.login.password_ != 888) {
        //做测试用,密码为888
        this.$message.error("密码错误");
      } else if (this.radio1 == "") {
        this.$message.error("请选择模式");
      } else {
        //这里是服务端计算密钥
        axios
          .post(`${填你自己的host}`, {
            userid: this.login.userId_,
            expire: 604800,
          })
          .then((res) => {
            this.$alert("登陆成功", "提示", {
              confirmButtonText: "确定",
              callback: (action) => {
                this.login.userSig_ = res.data;
                router.push({
                  name: "BasicTrtc",
                  params: {
                    userSig: this.login.userSig_,
                    userId: this.login.userId_,
                    //这里的sdkAppId 更好的情况应该设置为一个全局变量然后引入,这里偷懒了
                    sdkAppId: this.login.sdkAppId_,
                  },
                });
              },
            });
          })
          .catch((err) => {
            console.log(err);
          });
      }
    },
  },
};
</script>

服务端密钥计算

代码语言:txt
AI代码解释
复制
const tcb = require('@cloudbase/node-sdk')
const TLSSigAPIv2 = require('tls-sig-api-v2');
const Koa = require('koa');
const Router = require('koa-router');
const cors = require('koa2-cors');
const bodyParser = require('koa-bodyparser');


const app = new Koa();
const router = new Router();
app.use(sslify())
app.use(bodyParser());
app.use(cors());
app.use(router.routes()).use(router.allowedMethods());


router.get("/",  ctx => {
    ctx.body = 'Hello World';
});
router.post("/getUserSig",ctx => {
    if (ctx.method == 'OPTIONS') {
        ctx.body = 200; 
    } else {
        console.log(ctx.request.body);
        let {userid,expire} = ctx.request.body;
        //在后端做计算,这里的sdkappid和key可以写死
        let api = new TLSSigAPIv2.Api(1400349221, 
            '9ef0430a010*********************************037c6237ad3cd7710087e');
        let sig = api.genSig(userid, expire);
        ctx.body = sig;
    }
});

app.listen(8081);

这里一定要非常非常注意,由于TRTC底层封装的是WebRTC,WebRTC在服务器上必须只能在https协议下运行,因此一定要去配证书

前端计算可以参考官方Demo

房间选择

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<script>
// @ is an alias to /src
import TRTC from "trtc-js-sdk";
import axios from "axios";
import Vue from "vue";
import router from "../router";

export default {
  name: "BasicTrtc",
  components: {},
  data() {
    return {
      login: {
        sdkAppId_: "",
        userSig_: undefined,
        userId_: "",
        roomId_: "",
      },
      client_: null,
      localStream_: null,
      remoteStreams_: [],
      mic: "",
      micOptions: [],
      camera: "",
      cameraOptions: [],
      radio1: "",
    };
  },
  created() {
    TRTC.checkSystemRequirements().then((result) => {
      if (!result) {
        alert("Your browser is not compatible with TRTC");
      }
    });
  },
  async mounted() {
    this.login.roomId_ = 666888;
    this.login.userId_ = this.$route.params.userId;
    this.login.userSig_ = this.$route.params.userSig;
    this.login.sdkAppId_ = this.$route.params.sdkAppId;
    console.log(this.login);
    this.checkInfo();
  },
  methods: {
    async init() {
      const localStream = TRTC.createStream({ audio: true, video: true });
      localStream
        .initialize()
        .catch((error) => {
          console.error("failed initialize localStream " + error);
        })
        .then(() => {
          console.log("initialize localStream success");
          TRTC.getMicrophones().then((res) => {
            for (let item in res) {
              this.micOptions.push(res[item]);
            }
          });
          TRTC.getCameras().then((res) => {
            for (let item in res) {
              this.cameraOptions.push(res[item]);
            }
          });
          // 本地流初始化成功,可通过Client.publish(localStream)发布本地音视频流
        });
      this.localStream_ = localStream;
      this.$message({
        type: "info",
        message: `初始化完成!请选择输入输出设备`,
      });
    },
    async checkInfo() {
      if (this.login.userSig_ == undefined) {
        this.$alert("您未登录或登录态失效,请重新登录", "警告", {
          callback: (action) => {
            router.push({ name: "Login" });
          },
        });
      } else {
        this.init();
      }
    },
    async joinRoom() {
      switch(this.radio1){
        case '多人通话(会议)':
            router.push({
            name: "PrivateChatRoom",
            params: {
              userSig: this.login.userSig_,
              userId: this.login.userId_,
              sdkAppId: this.login.sdkAppId_,
              roomId:this.login.roomId_,
              mic:this.mic,
              camera:this.camera,
            },
          });
          break;
        case '语音聊天室':
            router.push({
              name:"IMChatRoom",
              params: {
                userSig: this.login.userSig_,
                userId: this.login.userId_,
                sdkAppId: this.login.sdkAppId_,
                roomId:this.login.roomId_,
                mic:this.mic,
                camera:this.camera,
              },
            })
          break;
        case '互动直播':
            router.push({
              name:"interactLive",
              params:{
                login:this.login,
                mic:this.mic,
                camera:this.camera,
              }
            })
          break;
         case '互动课堂':
            router.push({
              name:"interactClass",
              params:{
                login:this.login,
                mic:this.mic,
                camera:this.camera,
              }
            })
            break;
      }

     
    },
  },
};
</script>

这里的一个需要注意的是,为什么初始化要创建Stream,我们知道流是要放Client里才能使用的,一般正常的思路是先createClient 然后在createSteam 最后再把stream push到client里面去。但是由于部分浏览器的限制(主要是firefox,safari和一些chrome),对设备权限要求非常严格。没有流的话是不能直接授权设备的,而没有授权就无法获取设备ID(会出现undefined),则后面创建client的就无法创建,因此在这个界面里创建流并获取设备授权,并通过路由的形式传给房间

房间内

房间的大多数逻辑部分与官方demo既没有什么差别,基本流程如下图

image.png
image.png

唯一一个需要非常注意是在这里的最后三行,是该SDK接入Vue与jquery最大的不同之处

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
this.client_.on("stream-subscribed", (evt) => {
        const uid = evt.userId;
        const remoteStream = evt.stream;
        const id = remoteStream.getId();
        console.log(id);
        this.remoteStreams_.push(remoteStream);
        // objectFit 为播放的填充模式,详细参考:https://trtc-1252463788.file.myqcloud.com/web/docs/Stream.html#play
        Vue.nextTick().then(function () {
          remoteStream.play("remote_" + id, { objectFit: "contain" });
        });
      });

由于Vue的视图更新是自动监听有关视图的数据变化,数据一旦发生变化,视图随之变化,反之亦然,这是Vue的双向绑定机制,这里可以简单提一下:用Object.defineProperty( )的 set 与 get 来劫持属性的变化,然后告知Watcher,watcher中向所有订阅者更改视图。所以换句话说:更改视图这个行为什么时候完成,归属于底层,我们不能通过直接按顺序往下写代码就认为这是在视图更新完之后执行的

所以我们需要用到 Vue.nextTick().then(fn()) 这个全局函数

他可以让Vue在视图更新之后再执行后续代码

当然还有一种写法是在Vue的生命周期里的 updated 这里写,这时React的写法,后续如果出React的章节可以在这里完成。

以下是参考源码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<script>
import TRTC from "trtc-js-sdk";
import axios from "axios";
import Vue from "vue";
import router from "../router";

export default {
  data() {
    return {
      //这里请填入对应的sdkAppId
      login: {
        sdkAppId_: "",
        userSig_: undefined,
        userId_: "",
        roomId_: "",
      },
      circleUrl: "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
      squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
      sizeList: ["large", "medium", "small"],
      client_: null,
      isJoined_: false,
      isPublished_: false,
      isAudioMuted_: false,
      isVideoMuted_: false,
      localStream_: null,
      client_: null,
      localStream_: null,
      remoteStreams_: [],
      yourView_:true,
      mic: "",
      micOptions: [],
      camera: "",
      cameraOptions: [],
      members_: new Map(),
    };
  },
  async mounted() {
    const routerParams = this.$route.params;
    console.log(routerParams);
    this.login.roomId_ = routerParams.roomId;
    this.login.userId_ = routerParams.userId;
    this.login.userSig_ = routerParams.userSig;
    this.login.sdkAppId_ = routerParams.sdkAppId;
    this.mic = routerParams.mic;
    this.camera = routerParams.camera;
    await this.checkInfo();
    
  },
  methods: {
    async joinRoom() {
      if (this.login.roomId_ == "" || this.login.userId_ == "") {
        this.$message.error("请填写房间号/用户ID");
        return;
      }
      console.log(this.login);
      this.client_ = TRTC.createClient({
        mode: "rtc",
        sdkAppId: this.login.sdkAppId_,
        userId: this.login.userId_,
        userSig: this.login.userSig_,
      });
      this.handleEventsListen();
      if (this.isJoined_) {
        this.$message.warn("duplicate RtcClient.join() observed");
      }
      await this.client_
        .join({
          roomId: this.login.roomId_,
        })
        .then((res) => {
          this.$message.success("进房成功");
          this.isJoined_ = true;
          this.beginPushStream();
        })
        .catch((err) => {
          console.log(err);
          this.$message.error("进房失败!" + err);
        });
    },
    async leaveRoom() {
      if (!this.isJoined_) {
        this.$message.warn("leave() - please join() firstly");
        return;
      }
      // ensure the local stream is unpublished before leaving.
      await this.stopPushStream();

      // leave the room
      await this.client_.leave();
      this.isJoined_ = false;
      router.push({
        name: "BasicTrtc",
        params: {
          userSig: this.login.userSig_,
          userId: this.login.userId_,
          sdkAppId: this.login.sdkAppId_,
          roomId:this.login.roomId_
        },
      });
    },
    beginPushStream() {
      this.localStream_ = TRTC.createStream({
        audio: true,
        video: true,
        mirror: true,
        microphoneId: this.mic,
        cameraId: this.camera,
      });
      this.localStream_
        .initialize()
        .catch((error) => {
          console.log(error);
        })
        .then(() => {
          this.$message.success("initialize localStream success");
          // 本地流初始化成功,可通过Client.publish(localStream)发布本地音视频流
          if (!this.isJoined_) {
            console.warn("publish() - please join() firstly");
            return;
          }
          if (this.isPublished_) {
            console.warn("duplicate RtcClient.publish() observed");
            return;
          }
          this.client_.publish(this.localStream_).then(() => {
            // 本地流发布成功
            this.localStream_
              .play("local", { objectFit: "contain" })
              .then(() => {
                this.isPublished_ = true;
                // autoplay success
              })
              .catch((e) => {
                console.error("failed to publish local stream " + e);
                this.isPublished_ = false;
                const errorCode = e.getCode();
                if (errorCode === 0x4043) {
                  // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
                  // stream.resume()
                }
              });
          });
        });
    },
    async muteVideo(){
      if(this.localStream_.muteVideo()){
        this.isVideoMuted_ = true;
      }else{
        this.$message.error("muteVideo failed");
      }
       
    },
    async unmuteVideo(){
      if(this.localStream_.unmuteVideo()){
        this.isVideoMuted_ = false;
      }else{
        this.$message.error("unmuteVideo failed");
      }
    },
    async muteAudio(){
      if(this.localStream_.muteAudio()){
        this.isAudioMuted_ = true;
      }else{
        this.$message.error("unmuteVideo failed");
      }
    },
    async unmuteAudio(){
      if(this.localStream_.unmuteAudio()){
        this.isAudioMuted_ = false;
      }else{
        this.$message.error("unmuteVideo failed");
      }
    },
    async setSlience(){

    },
    async unsetSlience(){

    },
    async stopPushStream() {
      this.localStream_.stop();
      this.localStream_.close();
      if (!this.isJoined_) {
        console.warn("unpublish() - please join() firstly");
        return;
      }
      if (!this.isPublished_) {
        console.warn("RtcClient.unpublish() called but not published yet");
        return;
      }
      await this.client_.unpublish(this.localStream_);
      this.isPublished_ = false;
    },
    async checkInfo() {
      if (this.login.userSig_ == undefined) {
        this.$alert("您未登录或登录态失效,请重新登录", "警告", {
          callback: (action) => {
            router.push({ name: "Login" });
          },
        });
      } else if (this.mic == "" || this.camera == "") {
        this.$alert("未检测到您的麦克风或摄像头授权信息", "警告", {
          callback: (action) => {
            router.push({
              name: "BasicTrtc",
              params: {
                userSig: this.login.userSig_,
                userId: this.login.userId_,
                sdkAppId: this.login.sdkAppId_,
                mode: this.radio1,
              },
            });
          },
        });
      }else{
        await this.joinRoom();
      }
      
    },
    handleEventsListen() {
      console.log(this.client_);
      this.client_.on("stream-added", (evt) => {
        const remoteStream = evt.stream;
        const id = remoteStream.getId();
        const userId = remoteStream.getUserId();
        this.members_.set(userId, remoteStream);
        console.log(
          `remote stream added: [${userId}] ID: ${id} type: ${remoteStream.getType()}`
        );
        if (remoteStream.getUserId() === this.shareUserId_) {
          // don't need screen shared by us
          this.client_.unsubscribe(remoteStream);
        } else {
          console.log("subscribe to this remote stream");
          this.client_.subscribe(remoteStream);
        }
        console.log(this.remoteStreams_)
      });
      this.client_.on("stream-subscribed", (evt) => {
        const uid = evt.userId;
        const remoteStream = evt.stream;
        const id = remoteStream.getId();
        console.log(id);
        this.remoteStreams_.push(remoteStream);
        // objectFit 为播放的填充模式,详细参考:https://trtc-1252463788.file.myqcloud.com/web/docs/Stream.html#play
        Vue.nextTick().then(function () {
          remoteStream.play("remote_" + id, { objectFit: "contain" });
        });
      });
      this.client_.on("stream-removed", (evt) => {
        const remoteStream = evt.stream;
        const id = remoteStream.getId();
        remoteStream.stop();
        console.log(this.remoteStreams_);
        this.remoteStreams_ = this.remoteStreams_.filter((stream) => {
          return stream.getId() !== id;
        });
        console.log(
          `stream-removed ID: ${id}  type: ${remoteStream.getType()}`
        );
      });
      this.client_.on("mute-video",event => {
         console.log(this.remoteStreams_)
      })
      this.client_.on("unmute-video",event => {
         console.log(this.remoteStreams_)
      })
    },
  },
};
</script>

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
c++ primer2 变量和基本类型。
这四种初始化方式c++11都是支持的。c++11中用花括号来初始化变量得到了全面应用。
和蔼的zhxing
2018/09/04
5410
Modern c++快速浅析
•template<typename T> void func(T& param);在这个示例函数中,如果传递进是一个const int&的对象,那么T推导出来的类型是const int,param的类型是const int&。可见引用性在型别推导的过程中被忽略•template<typename T> void func(T param);在这个示例函数中,我们面临的是值传递的情景,如果传递进的是一个const int&的对象,那么T和param推导出来的类型都是int如果传递进的是一个const char* const的指针,那么T和param推导出来的类型都是const char*,顶层const被忽略。因为这是一个拷贝指针的操作,因此保留原指针的不可更改指向性并没有太大的意义
高性能架构探索
2024/01/03
2260
Modern c++快速浅析
C++11基础学习系列一
---- 概述 C++11标准越来越趋于稳定和成熟,国外c++11如火如荼而国内却依然处于观望期。每当提到C++很多程序员都很抵触,特别是学术界的呼声更高一些。其实不然,语言即工具,语言的好坏不在于本身,而在于驾驭它和适用它所在的范围所决定的。那么为什么国内大多数程序员都会遭到抵触呢?我觉得原因有如下(不要劈我,仅此个人意见): C++是对C语言进行了抽象同时又支持了很多面向对象的特性,在趋于底层设计时又对上层进行封装和扩展。它是从计算机科学层面去设计和演化的,如果想写出高效和稳定的程序,那么你就必须具备基
吕海峰
2018/04/03
9320
C++11基础学习系列一
C++11——引入的新关键字
auto是旧关键字,在C++11之前,auto用来声明自动变量,表明变量存储在栈,很少使用。在C++11中被赋予了新的含义和作用,用于类型推断。
恋喵大鲤鱼
2018/08/03
1.5K0
C++ 的发展
C++ 是由 Bjarne Stroustrup 于 1979 年在贝尔实验室(Bell Labs)开始开发的,最初是作为 C 语言的一个扩展,目的是在不丧失 C 语言高效性的基础上,提供面向对象编程的特性。C++ 的发展历程可以分为以下几个重要阶段:
ljw695
2024/11/15
6730
C++ 的发展
C++11新关键字
auto是旧关键字,在C++11之前,auto用来声明自动变量,表明变量存储在栈,很少使用。在C++11中被赋予了新的含义和作用,用于类型推断。
恋喵大鲤鱼
2019/02/22
3.1K0
《Effective Modren C++》 进阶学习(上)
  作为一名有追求的程序猿,一定是希望自己写出的是最完美的、无可挑剔的代码。那完美的标准是什么,我想不同的设计师都会有自己的一套标准。而在实际编码中,如何将个人的标准愈发完善,愈发得到同事的认可,一定需要不断积累。如何积累,一定是从细微处着手,观摩优秀的代码,学习现有的框架,汲取前人留下的智慧。
开源519
2023/11/15
2270
《Effective Modren C++》 进阶学习(上)
【C++终极篇】C++11:编程新纪元的神秘力量揭秘
但是到了c++11实现了可以用{}对容器进行一些初始化等,比如push/inset多参数构造的对象时,{}初始化会很⽅便,这是因为每个类型它都会有个initializer_list的一个构造,这样就方便了我们操作。
用户11458826
2025/01/23
350
【C++终极篇】C++11:编程新纪元的神秘力量揭秘
c++基础之变量和基本类型
之前我写过一系列的c/c++ 从汇编上解释它如何实现的博文。从汇编层面上看,确实c/c++的执行过程很清晰,甚至有的地方可以做相关优化。而c++有的地方就只是一个语法糖,或者说并没有转化到汇编中,而是直接在编译阶段做一个语法检查就完了。并没有生成汇编代码。也就是说之前写的c/c++不能涵盖它们的全部内容。而且抽象层次太低,在应用上很少会考虑它的汇编实现。而且从c++11开始,加入了很多新特性,给人的感觉就好像是一们新的编程语言一样。对于这块内容,我觉得自己的知识还是有欠缺了,因此我决定近期重新翻一翻很早以前买的《c++ primer》 学习一下,并整理学习笔记
Masimaro
2021/01/20
1.6K1
【笔记】《C++Primer》—— 第2章
这本书真是可怕,越看才越是知道自己欠缺的东西是有多么多...第二章又看到了很多不明白的东西,还有一些C11才带来的全新的概念,结果这篇可能会稍长一点,好多东西值得慢慢消化呢。
ZifengHuang
2020/07/29
5480
【笔记】《C++Primer》—— 第2章
c++从入门到进阶--引用与常量
constexpr必须用常量表达式初始化,也就是说必须在编译过程就能计算出结果(若要用函数作为constexpr的初始值那么该函数应该是constexpr类型的函数)。
风骨散人Chiam
2020/10/28
8080
Effective Modern C++翻译(2)-条款1:明白模板类型推导
第一章 类型推导 C++98有一套单一的类型推导的规则:用来推导函数模板,C++11轻微的修改了这些规则并且增加了两个,一个用于auto,一个用于decltype,接着C++14扩展了auto和decltype可以使用的语境,类型推导的普遍应用将程序员从必须拼写那些显然的,多余的类型的暴政中解放了出来,它使得C++开发的软件更有弹性,因为在某处改变一个类型会自动的通过类型推导传播到其他的地方。 然而,它可能使产生的代码更难观察,因为编译器推导出的类型可能不像我们想的那样显而易见。 想要在现代C++中进行有效
magicsoar
2018/02/06
8010
C++中变量声明与定义的规则
为了支持分离式编译,C++将定义和声明区分开。其中声明规定了变量的类型和名字,定义除此功能外还会申请存储空间并可能为变量赋一个初始值。
TOMOCAT
2021/04/20
2.4K0
c++11新特性,所有知识点都在这了!
本文基本上涵盖了c++11的所有新特性,并有详细代码介绍其用法,对关键知识点做了深入分析,对重要的知识点我单独写了相关文章并附上了相关链接,我整理了完备的c++新特性脑图(由于图片太大,我没有放在文章里,同学可以在后台回复消息“新特性”,即可下载完整图片)。
公众号guangcity
2020/11/10
21K10
c++11新特性,所有知识点都在这了!
C++11新特性学习笔记
C++11标准为C++编程语言的第三个官方标准,正式名叫ISO/IEC 14882:2011 - Information technology – Programming languages – C++。在正式标准发布前,原名C++0x。它将取代C++标准第二版ISO/IEC 14882:2003 - Programming languages – C++成为C++语言新标准。
CtrlX
2023/03/13
2.3K0
C++11新特性学习笔记
『C++』我想学C++,C++太难了,那我想入门,给我10分钟我带你入门
就是一条预处理命令, 它的作用是通知C++编译系统在对C++程序进行正式编译之前需做一些预处理工作,导入头文件下的函数,与类。
风骨散人Chiam
2020/10/28
1.6K0
每个C++开发者都应该学习和使用的C++11特性
Hi,大家好!本文讨论了所有开发人员都应该学习和使用的一系列 C++11特性。该语言和标准库中有很多新增功能,本文只是触及了皮毛。但是,我相信其中一些新功能应该成为所有C++开发人员的日常工作。
Linux兵工厂
2024/03/21
940
每个C++开发者都应该学习和使用的C++11特性
C++ 11 新特性
nullptr\text{nullptr}nullptr 的出现是为了取代 NULL\text{NULL}NULL,避免 NULL\text{NULL}NULL 的二义性。
f_zyj
2019/05/27
7760
C++20新特性个人总结
concept乃重头戏之一,用于模板库的开发。功能类似于C#的泛型约束,但是比C#泛型约束更为强大。
用户7886150
2021/02/04
2K0
C++入门知识(二)
用这种方式声明的引用,不能通过引用对目标变量的值进行修改,从而使引用的目标成为const,达到了引用的安全性。
海盗船长
2020/08/27
5470
相关推荐
c++ primer2 变量和基本类型。
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文