c++ learning note
1/ int 转换成 string 格式
#include<sstream>
std::stringstream ss;
str::string temp;
int n;
ss<<n;
ss>>temp;
//再次使用时 需要 ss.clear(); 或者重新定义
方法1:
string转换成int
atoi(str.c_str()) 函数
string s; int re;
re= atoi(s.c_str());
方法2 :
int b= stoi(string a);
3.c++中指针数组和数组指针作为函数参数时,该如何传递
#include<iostream>
#include<cstdio>
using namespace std; void FuncT(int iNum, char *asIP[])
{
for (int i = ; i < iNum; ++i)
{
printf("%s\n", asIP[i]);
}
}
int main()
{
char asIP[][];
cout << asIP << " " << asIP[] << endl;
char *p[] ;
p[] = asIP[];
p[] = asIP[]; strcpy_s(asIP[], "172.2.2.1");
strcpy_s(asIP[], "172.23.3.2"); FuncT(, p);
system("pause");
return ;
}
//形参和实参的匹配形式
// 实参 形参
**p **p
p[][] (*p)[]
*p[] **p
(*p)[] *p
#include <mem.h>
void* memset(void* s, int c, size_t n)
{
unsigned char* p = (unsigned char*) s;
while (n > 0) {
*p++ = (unsigned char) c;
--n;
}
return s;
}
memset()的函数, 它可以一字节一字节地把整个数组设置为一个指定的值。
memset()函数在mem.h头文件中声明,它把数组的起始地址作为其第一个参数,
第二个参数是设置数组每个字节的值,第三个参数是数组的长度(字节数,不是元素个数)。
4/ C++中禁止 拷贝构造函数 和 赋值构造函数
设为private ,但是这种方法 它的 friend class 和 friend 函数 都可以访问拷贝构造
c++11 标准中可以通过delete操作禁掉 他们
T(T&temp)=delete; // 再次调用拷贝构造函数 会报错
T& operator=(T&temp)=delete;
5/ 随机函数 rand()/ srand()
rand stdilb.h 中
rand() 产生的是伪随机数,每次产生的是相同的值
如果想要产生不同的随机数用srand函数
srand((unsigned)time(0));
c++ learning note的更多相关文章
- Learning note for Binding and validation
Summary of my learning note for WPF Binding Binding to DataSet. when we want to add new record, we s ...
- Learning Note: SQL Server VS Oracle–Database architecture
http://www.sqlpanda.com/2013/07/learning-note-sql-server-vs.html This is my learning note base on t ...
- Course Machine Learning Note
Machine Learning Note Introduction Introduction What is Machine Learning? Two definitions of Machine ...
- shell learning note
shell learning note MAIN="/usr/local/" # 变量大写 STATUS="$MAIN/status" # 美元符加字符串是 ...
- 2014/09/30 Learning Note
Vbird Linux: Vim Learning: http://linux.vbird.org/linux_basic/0310vi.php Bash Shell: http://linux.vb ...
- [Angular2] @Ngrx/store and @Ngrx/effects learning note
Just sharing the learning experience related to @ngrx/store and @ngrx/effects. In my personal opinio ...
- Machine Learning Note Phase 1( Done!)
Machine Learning 这是第一份机器学习笔记,创建于2019年7月26日,完成于2019年8月2日. 该笔记包括如下部分: 引言(Introduction) 单变量线性回归(Linear ...
- Inheritance Learning Note
好几天没来学习了,昨晚把继承的又整理了一下.想把整理后的东西发到hexo博客上来,却发现命令行又失效了.前几天明明是好的,这几天又没有进行任何操作,网上搜了一下也没有招到合适的解决办法,无奈只能重装了 ...
- Machine Learning Note
[Andrew Ng NIPS2016演讲]<Nuts and Bolts of Applying Deep Learning (Andrew Ng) 中文详解:https://mp.weixi ...
- Java: some learning note for Java calssloader and Servlet
1. Java Classloader 链接: https://en.wikipedia.org/wiki/Java_Classloader 摘要: The Java Classloader is a ...
随机推荐
- javascript笔记图
1.this 2.对象 3.继承 4.跨域 5.事件 6.基础
- Autodesk 最新开发技术研讨会 -8月22日-Autodesk北京办公室
为了增进与广大中国地区Autodesk产品的二次开发人员的了解与互动,帮助中国地区的Autodesk产品二次开发人员了解Autodesk最新的二次开发技术动向,并获得Autodesk公司专业开发支持顾 ...
- Spring AOP 四大通知
Spring AOP 四大通知 Spring 3.X 以前 1.前置通知,实现 MethodBeforeAdvice 接口,重写 public void before(Method metho ...
- ReactiveCocoa学习总结
最近一直断断续续学习关于ReactiveCocoa的知识内容,对于它的一些基础内容将通过本文进行一个总结,主要是一些入门知识 一:RACSignal一些运用 @interface RACSignalT ...
- iOS之 opencv3.0.framework
本文章的目的是从源代码包中编译出opencv2.framework供IOS开发使用. 基本上是按照http://docs.opencv.org/3.0-beta/doc/tutorials/intro ...
- 基于ZooKeeper的Dubbo注册中心
SOA服务治理 dubbo_zk 服务总线 感兴趣的M我微信:wonter 微信扫描,人人 CTO 大本营 基于SOA架构的TDD测试驱动开发模式 服务治理要先于SOA 简述我的SOA服务治理 从页面 ...
- symfony2 controller
1.基本概念 一次http请求 输入(Request):header信息.get信息.post数据等 输出(Response):symfony经过处理返回的信息,包括页面.json字符串.URL ...
- C# 获取 新浪微博登录之后的 完整的Cookie
程序说明: 1.此项目 包含两个项目, 一个 Winform WinGetMocroblogCookie 用于手动 登录 新浪微博 其中涉及到的技术有: 使用webbrowser 获取HttpOnly ...
- 神奇的decimal,也许面试会问到哦~
这段时间忙的像狗一样,写博客的事情也就耽搁了,继续扯,为什么说decimal神奇呢,大家都知道decimal是基元类型,但是 这个decimal类型在IL中居然没有相应的IL指令,也就是说CLR根本不 ...
- Windows自动关机命令
winxp中自带了自动关机功能,在开始→运行中使用SHUTDOWN命令 1. 延迟关机关机 shutdown -s -t 120 -s为关机:-t为时间,以秒为单位,120表示2分钟 表示两分钟后关机 ...