`
sai_ruby
  • 浏览: 22462 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

C++笔记(2)

阅读更多
dynamic_cast
dynamic_cast can be used only with pointers and references to objects. Its purpose is to ensure that the result of the type conversion is a valid complete object of the requested class. Therefore, dynamic_cast is always successful when we cast a class to one of its base classes:

static_cast
static_cast can perform conversions between pointers to related classes, not only from the derived class to its base, but also from a base class to its derived. This ensures that at least the classes are compatible if the proper object is converted, but no safety check is performed during runtime to check if the object being converted is in fact a full object of the destination type. Therefore, it is up to the programmer to ensure that the conversion is safe. On the other side, the overhead of the type-safety checks of dynamic_cast is avoided.

reinterpret_cast
reinterpret_cast converts any pointer type to any other pointer type, even of unrelated classes. The operation result is a simple binary copy of the value from one pointer to the other. All pointer conversions are allowed: neither the content pointed nor the pointer type itself is checked. It can also cast pointers to or from integer types. The format in which this integer value represents a pointer is platform-specific. The only guarantee is that a pointer

const_cast
This type of casting manipulates the constness of an object, either to be set or to be removed. For example, in order to pass a const argument to a function that expects a non-constant parameter:

typeid
typeid allows to check the type of an expression:
typeid (expression)
This operator returns a reference to a constant object of type type_info that is defined in the standard header file <typeinfo>. This returned value can be compared with another one using operators == and != or can serve to
obtain a null-terminated character sequence representing the data type or class name by using its name() member.
分享到:
评论

相关推荐

    千锋C++笔记.zip

    《千锋C++笔记》是一份综合性的学习资料,涵盖了C++编程语言的基础到高级概念。这份笔记由知名教育机构“千锋”提供,旨在帮助初学者和有一定基础的程序员深入理解和掌握C++这一强大的系统级编程语言。下面将详细...

    C++笔记.rar C++笔记.rar

    这份"C++笔记"包含了学习C++时的重要知识点和实践技巧。 1. **基础语法**:C++的基础包括变量、数据类型(如整型、浮点型、字符型等)、运算符(算术、比较、逻辑、位运算符等)、流程控制语句(如if-else、switch-...

    C++学习笔记本

    C++学习笔记C++学习笔记C++学习笔记C++学习笔记C++学习笔记

    c++学习笔记精华版

    ### C++ 学习笔记精华版 #### 一、C++ 语言概述 **1、历史背景** - **C++ 的江湖地位** - Java、C、C++、Python、C# 是当前主流的编程语言之一,而 C++ 在这些语言中以其高效性和灵活性著称。 - **C++ 之父 ...

    C++笔记.md

    C++笔记.md

    自考C++笔记(上)

    "自考C++笔记(上)" 本笔记是作者全部手打创作的自考C++笔记,包含课本中例子的详细分析,共47200字,适合没有学过C语言的人认真学习和通过C++自考。 C++程序设计 ### 认识 C++的对象 #### 1.1 初识 ...

    C++学习笔记.pdf

    C++学习笔记

    C++笔记C++笔记C++笔记C++笔记

    我自己的笔记,根据C++知识点来概括,里面有例子,详解,也有一些重点算法(10个),关键是类,结构,函数的笔记,唉。。自己记录的,写得很鸟的,只适合鸟鸟们看,高手千万不要下,不然笑话我啊。但写得辛苦,10分...

    某课网C++笔记pdf

    2. **运行安装程序**:挂载成功后,找到并运行安装程序(setup.exe),按照提示完成安装过程。 ### 数据类型及初始化 在C++中,数据类型是程序设计的基础。理解不同数据类型的特性和如何正确初始化这些类型非常...

    大一下c++笔记.md

    大一下c++笔记.md

    钱能的C++笔记,绝对值的珍藏.rar

    《钱能的C++笔记——绝对值的珍藏》是一份深受C++爱好者和学习者欢迎的资源,它以其详实的内容和实用价值赢得了高度评价。这份笔记主要聚焦于C++编程语言,深入探讨了其核心概念、语法特性以及编程技巧。 首先,C++...

    C++笔记(1).md

    C++笔记(1).md

    c++学习笔记.pdf

    2. C++中的构造函数有几种类型:默认构造函数、拷贝构造函数、委托构造函数等。构造函数是在创建对象时自动调用的特殊成员函数,用于初始化对象的成员变量。 3. 结构体内存对齐是C++中为了提高内存存取效率而采取的...

    达内C/C++笔记

    C++笔记可能涵盖了C++的更多高级特性,如模板元编程、STL的深度使用、设计模式、多线程编程、Boost库的运用等。这些内容可以帮助开发者写出更加高效、可维护的代码。 1. **模板元编程**:在编译时进行计算,减少...

    C++笔记初学者的期末老师

    总的来说,C++笔记对于初学者来说是一份宝贵的学习资料,它涵盖了C++的基础知识,如程序结构、面向对象特性、函数的使用等,这些都是学习C++必备的基础。通过深入理解和实践这些概念,初学者可以逐步掌握C++编程,并...

    c++笔记.txt

    根据提供的文件信息,可以看出这份文档主要涉及C++中的一些关键概念和知识点,特别是关于静态成员、友元类、以及常量等内容。接下来,我们将详细解释这些知识点。 ### 静态成员 静态成员(包括静态数据成员和静态...

    C++Primer读书笔记:C++概述.pdf

    C++Primer中文第三版(C++从入门到精通)第一章的读书笔记,主要是C++程序、预处理器指示符、iostream库等的基础知识点读书笔记。

    c++完美学习笔记c++完美学习笔记c++完美学习笔记

    C++学习笔记 本资源摘要信息涵盖了C++语言的学习笔记,涵盖了C++的基本语法、数据类型、运算符、控制结构、函数、数组、指针、类和对象、继承、多态、异常处理等方面的知识点。 1. 方法标记事务的开始 在录制Vuser...

    黑马C++学习笔记

    "黑马C++学习笔记" 本笔记主要记录了C++的基础知识和一些重要的概念,包括变量的声明、赋值、输出、引用、指针、结构体等。 变量声明和赋值 在C++中,变量的声明和赋值是非常重要的。变量可以是整数、浮点数、...

Global site tag (gtag.js) - Google Analytics