我正在创建一个地图,仅用于学习目的,以存储一些键值对.如果我使用begin()
函数打印第二个地图字段,我可以打印地图的第二个字段,但是当我尝试使用end()
它的最后一个元素相同时,它无法打印第二个字段.以下是我的代码:
#include <iostream>
#include <cstdlib>
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
map<int,std::string> arr;
map<int,std::string>::iterator p;
int main(int argc, char** argv) {
arr[1] = "Hello";
arr[2] = "Hi";
arr[3] = "how";
arr[4] = "are";
arr[5] = "you";
p = arr.begin();
printf("%s\n",p->second.c_str());
p = arr.end();
printf("%s\n",p->second.c_str());
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个小型视频流应用程序。我想获取Android中网络的上传和下载速度。我发现我们可以通过使用Android NetworkCapability类提供的功能来做到这一点
getLinkDownstreamBandwidthKbps()
Retrieves the downstream bandwidth for this network in Kbps.
This always only refers to the estimated first hop transport bandwidth.
getLinkUpstreamBandwidthKbps ()
Retrieves the upstream bandwidth for this network in Kbps.
This always only refers to the estimated first hop transport bandwidth.
Run Code Online (Sandbox Code Playgroud)
1.这里的第一跳是什么意思?
2.如何使用它们。请提供一些链接供参考,我们如何使用它们?
当我遇到数据运算符时,我只是在阅读有关向量的内容.在下面的示例中,正在使用数据运算符.
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector (5);
int* p = myvector.data();
*p = 10;
++p;
*p = 20;
p[2] = 100;
std::cout << "myvector contains:";
for (unsigned i=0; i<myvector.size(); ++i)
std::cout << ' ' << myvector[i];
std::cout << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
myvector contains: 10 20 0 100 0
Run Code Online (Sandbox Code Playgroud)
我的问题是为什么0在100和100的位置向后移动一个位置.如:
p
是等值的myvector[0]
,给定值10
.++p;
现在p
指向给myvector[1]
定的价值20
20
,100
应该来,为什么会这样0
.