Modern C++ Course [Lecture 6] {Static, Numbers in memory, Raw C arrays, Non-owning pointers, Classes in memory}

every object of the same class can equally gets access to the static variable

float has limited precision, eg, float x = 1.0;

but x = 0.99999987 things like this.

destroy precision of demicals when add huge numbers to small numbers

 set precision(20)

10M + PI

1M + PI

length of decimal part is nonlinear....???

there‘s no way of knowing in the function what‘s the size of the array you are passing.

and you can read any memory you want and this is dangerous

just make it a rule, never ever create a pointer without initialization.

if a nullptr is used without further declaration, compiler would show you a "segmentation error"

custom objects have variables in memeory stored together, but some padding may be inserted.

原文地址:https://www.cnblogs.com/ecoflex/p/10201933.html

时间: 2024-08-30 06:51:31

Modern C++ Course [Lecture 6] {Static, Numbers in memory, Raw C arrays, Non-owning pointers, Classes in memory}的相关文章

Modern C++ Course [Lecture 2] {Compilation, Debugging, Functions, Header/Source, Libraries, CMake}

http://www.ipb.uni-bonn.de/wp-content/uploads/2018/05/lecture_2.pdf  make bash file executable Wall: Warning all Wextra: add even more extra Warning Werror: treat Warnings as errors by default, there's no optimization. -O0 -O3 -Ofaster "segmentation

Modern C++ Course [Lecture 7] {Pointers, const with pointers, Stack and Heap, Memory leaks, Dangling pointers}

https://en.cppreference.com/w/cpp/language/range-for every object has a pointer to itsleft. stack operations are very quick it's computationally expensive to search variables in a stack, when the scopes and functions are very large. So, keep your sco

Scanner类、匿名对象、Random类、String类、static静态类、math类和Arrays工具类

一.Scanner类 1.除了八种基本数据类型,其他都是引用类型: 引用类型使用三步骤: 2.Scanner类 引用jdk提供的类,Scanner在java.util包下,不在java.lang包(String)下使用的都要import,查找jdk api,看构造方法创建对象,再看成员方法实现功能: 3.Scanner实现在控制台接收键盘输入的两个Int值相加 4.Scanner类比较找出三个数中最大值 二.匿名对象 1.只使用一次:因为每次new都创建新的对象,再使用时候找不到那个堆内存中的之

How I Wrote a Modern C++ Library in Rust

https://hsivonen.fi/modern-cpp-in-rust/ Since version 56, Firefox has had a new character encoding conversion library called encoding_rs. It is written in Rust and replaced the old C++ character encoding conversion library called uconv that dated fro

Delphi DLL制作和加载 Static, Dynamic, Delayed 以及 Shared-Memory Manager

一 Dll的制作一般分为以下几步:1 在一个DLL工程里写一个过程或函数2 写一个Exports关键字,在其下写过程的名称.不用写参数和调用后缀.二 参数传递1 参数类型最好与window C++的参数类型一致.不要用DELPHI的数据类型.2 最好有返回值[即使是一个过程],来报出调用成功或失败,或状态.成功或失败的返回值最好为1[成功]或0[失败].一句话,与windows c++兼容.3 用stdcall声明后缀.4 最好大小写敏感.5 无须用far调用后缀,那只是为了与windows 1

Memory Ordering in Modern Microprocessors

Linux has supported a large number of SMP systems based on a variety of CPUs since the 2.0 kernel. Linux has done an excellent job of abstracting away differences among these CPUs, even in kernel code. One important difference is how CPUs allow memor

CS224d lecture 12札记

欢迎转载,转载注明出处: http://www.cnblogs.com/NeighborhoodGuo/p/4711678.html CS224d的第十一课是他们的课上考试,所以后面的视频就直接跳到lecture 12了.lecture 12是一位外宾过来讲得,据说是Facebook的工程师,讲了现在最前沿的AI research,AI很多东西在全世界范围内都没有解决方案或者说对某一问题有统一的意见,所以这堂课不是介绍一个成熟的model,可以理解这一讲是为大家打开一扇门,让大家了解AI中的这部

《modern operating system》 chapter 3 MEMORY MANAGEMENT 笔记

MEMORY MANAGEMENT The part of the operating system that manages (part of) the memory hierarchy is called thememory manager 这章感觉有点多...80 多页..看完都看了两天多,做笔记就更有点不想...有点懒了..但是要坚持下去,可以自己较劲 对于内存的抽象,最简单的抽象就是...没有抽象 和第一次看不一样,把summary放在最前面,对整个mamory management的

关于 static 和 final 的一些理解

---恢复内容开始--- 今天主要回顾一下 static 和 final 着两个关键字. 1. static  -  静态 修饰符 - 用于修饰数据(变量.对象).方法.代码块以及内部类.     1.1 静态变量 用static修饰变量,称之为静态变量,也叫类变量.在类加载的时候加载到了方法区,并且在方法区中被赋予了默认值.静态变量是先于对象出现的,所以习惯上是通过类名来调用静态变量.每一个对象存储的是这个静态变量在方法区中的地址,所以静态变量是被这个类的所有对象所共享的. 静态变量能否定义到