![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
C++
文章平均质量分 89
C++学习笔记
紫薯真好吃
制定计划,不拖沓并且持之以恒~
展开
-
Difference between new operator in C++ and new operator in java
In C++(1)Method 1 (usingnew)MyClass* myClass = new MyClass();myClass->MyField = "Hello world!";Allocates memory for the object on thefree store(This is frequently the same thing as theheap) Requires you to explicitlydeleteyour object lat...转载 2021-01-16 16:31:58 · 87 阅读 · 0 评论 -
cout 输出数组名和字符数组名/ 输出地址,cout对字符数组重载
char a[] = {'a','b','c'}; char b[] = "abc"; char c[] = { 'a','b','c','\0'}; int d[] = {1,2,3 }; cout << a << endl; cout << b << endl; cout << c << endl; cout << d << en...转载 2020-12-03 13:21:26 · 6874 阅读 · 0 评论 -
java(C/C++), python 中的除法取整
编程中的除法编程中的除法分为三种: 向上取整:即在所有计算的结果中,取最接近+∞的那个值为最终的商。如10 ÷ (-3) = -3……1而不是10 ÷ (-3) = -4……-2。 向下取整:同理,在所有计算的结果中,取最接近-∞的那个值为最终的商。如-10 ÷ 3 = -4……2而不是-10 ÷ 3 = -3……-1。 向零取整:即,在所有计算的结果中,取最接近0的那个值为最终的商。 经过推理运算和查阅书籍发现:Java、C/C++遵循的取整方式为:向零取整Pyth转载 2020-10-06 16:44:26 · 796 阅读 · 0 评论 -
string::substr
std::string::substrstring substr (size_t pos = 0, size_t len = npos) const;Generate substringReturns a newly constructedstringobject with its value initialized to a copy of a substring of this object.The substring is the portion of the object tha..转载 2020-09-24 11:14:44 · 424 阅读 · 0 评论 -
Lambda Expressions in C++
转自:https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=vs-2019In this articleRelated Topics Parts of a Lambda Expression constexpr lambda expressions Microsoft-specific See alsoIn C++11 and later, a lambda expressi..转载 2020-09-22 21:13:47 · 859 阅读 · 0 评论 -
二维vector初始化方法
方法1:#include<iostream>#include<vector> void main(){ int a = 2; int b = 4; //初始化方法1 //std::vector<std::vector<int>> vec(a, std::vector<int> (b)); //2行4 vector<vector<int>> vec(a, vector<转载 2020-09-16 17:29:32 · 1118 阅读 · 0 评论 -
C++ 指针
C++ Pointers转自:https://www.tutorialspoint.com/cplusplus/cpp_pointers.htmPrevious PageNext PageC++ pointers are easy and fun to learn. Some C++ tasks are performed more easily with pointers, and other C++ tasks, such as dynamic memory allocation,...转载 2020-09-13 18:14:04 · 76 阅读 · 0 评论 -
C++中Vector和List 的不同
Difference between Vector and List in C++In this article we will discuss the differences between std::vector and std::list in C++.Both vector and list are sequential containers of C++ Standard Template Library. But there are many differences betw..转载 2020-09-13 10:42:39 · 138 阅读 · 0 评论 -
C++函数调用之——值传递、指针传递、引用传递
C++函数调用之——值传递、指针传递、引用传递1、简介 1、值传递:形参时实参的拷贝,改变函数形参并不影响函数外部的实参,这是最常用的一种传递方式,也是最简单的一种传递方式。只需要传递参数,返回值是return考虑的;使用值传递这种方式,调用函数不对实参进行操作,也就是说,即使形参的值发生改变,实参的值也完全不受影响。 2、指针传递:指针传递其实是值传递的一种,它传递的是地址。值传...转载 2020-03-29 18:26:42 · 546 阅读 · 0 评论 -
C++ 中 什么时候不用new?什么时候用new?
不new和new的区别(1)类型分配的内存位置:不new的类型对象内存分配是在栈区,这个地方比较小,一般只有几M的空间。一般对于内置类型比如int、char等如果需要的内存不多的情况下,可以不用new。这时候的内存会在当前函数结束后自动释放。需要New的时候一般对于复杂类型,这时候内存分配是在堆区。比如自定义的类类型,或者需要大量内存空间的时候,比如你需要一个10000个int的数组,这...原创 2020-03-19 16:00:37 · 6221 阅读 · 0 评论