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实现的2048
HTML代码如下 <!DOCTYPE html> <html> <head> <title></title> <meta charse ...
- HHKB MAC 配置指南 操作指南 快捷键
1. 设备: mac电脑一台.hhkb键盘一个 2. 初级配置 (1)调节hhkb的模式为Macintosh模式:011001 (打开键盘侧边的滑盖,按照这个顺序调正) (2)Mac电脑安装官方驱动 ...
- Windows服务器如何选 搭建WAMP环境
Windows Server 2003 Windows Server 2008 如何选择服务器系统版本.原文地址:http://www.xwamp.com/learn/1. 系统版本: Windows ...
- 总结CSS3新特性(Animation篇)
动画(Animation),是CSS3的亮点.//之一 通过animation属性指定@keyframe来完成关键帧动画; @keyframe用法: @keyframes name { 0% { to ...
- CART(分类回归树)
1.简单介绍 线性回归方法可以有效的拟合所有样本点(局部加权线性回归除外).当数据拥有众多特征并且特征之间关系十分复杂时,构建全局模型的想法一个是困难一个是笨拙.此外,实际中很多问题为非线性的,例如常 ...
- 盒图(boxplot)
最近在摆弄数据离散度的时候遇到一种图形,叫做盒图(boxplot).它对于显示数据的离散的分布情况效果不错. 盒图是在1977年由美国的统计学家约翰·图基(John Tukey)发明的.它由五个数值点 ...
- 用swift实现自动录音器
基本介绍 自动录音与一般录音区别在:不用像微信那样按下录音-松手结束,而是根据说话声音的大小自动判断该录音和该停止的点,然后可以做到结束录音之后马上播放出来.类似于达到会说话的汤姆猫那样的效果. 在自 ...
- xmpp整理笔记:用户网络连接及好友的管理
xmpp中的用户连接模块包括用户的上线与下线信息展现,用户登录,用户的注册: 好友模块包括好友的添加,好友的删除,好友列表的展示. 在xmpp中 负责数据传输的类是xmppStream,开发的过程中, ...
- spring.net (2)环境搭建 对(1)例子的解释和扩充
在上文中的例子实现了spring.net 控制反转的简单例子: 但是不免其中会有一些疑问. 例子中的配置文件是什么意思: app.config的配置规则可以参考web.config的配置详情 < ...
- UIApplicationDelegate
App受到干扰时,UIApplication会通知它的delegate对象,让delegate处理系统事件. 项目中的AppDelegate已经遵守了UIApplicationDelegate协议 ...