例如,如果我有这样的mmap:
alice -> 30
bob -> 23
josh -> 20
josh -> 30
andy -> 40
andy -> 40
Run Code Online (Sandbox Code Playgroud)
只得到这对:
alice -> 30
bob -> 23
josh -> 20
andy -> 40
Run Code Online (Sandbox Code Playgroud) 我的尝试:
class myClass {
std::vector<int> myVector;
public:
myClass(std::vector<int> &v) {
this->myVector = v;
}
void doSomething() {
for (int &num : this->myVector) {
num += 100;
}
}
};
Run Code Online (Sandbox Code Playgroud)
在main()中:
vector<int> myVect = {1,2,3,4};
myClass myClassInst(myVect);
myClassInst.doSomething();
Run Code Online (Sandbox Code Playgroud)
但随后检查:
for (int i : myVect) {
printf("%i\n", i);
}
Run Code Online (Sandbox Code Playgroud)
不对原始矢量进行更改.
我在这里尝试向后迭代多映射键,功能与硬编码类型的工作原理.
#include <map>
#include <string>
#include <iostream>
using namespace std;
multimap<int, string> mm = { {1, "a"}, {1, "lemon"}, {2, "peacock"}, {3, "angel"} };
void printKeysBackwards(multimap<int, string> mm) {
typedef multimap<int, string> multimap_type;
typedef std::reverse_iterator<multimap_type::iterator> reverse_iterator;
for (auto it = mm.rbegin(), end = mm.rend(); it != end;
it = reverse_iterator(mm.lower_bound(it->first))) {
cout << (*it).first << endl;
}
}
int main() {
printKeysBackwards(mm);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试模板功能时:
template <class Key, class Val>
void printKeysBackwards(multimap<Key, Val> mm) {
typedef multimap<Key, Val> multimap_type; …Run Code Online (Sandbox Code Playgroud) 将.wmv文件转换为.mp4时,我使用了以下命令:
exec("ffmpeg -i file.wmv -vcodec mpeg4 -acodec libfaac -b 1200 -r 15 -s 320x240 -pix_fmt yuv420p file.mp4");
声音很好但我没有图像(使用html5时没有下载到电脑上).这是输出:
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale …Run Code Online (Sandbox Code Playgroud) 像这样:if($ sth)make_private($ this-> method);
或者可能有其他方法来影响方法的可访问性?
问题是我编写了一个必须调用一次方法的类,所以我需要代码在执行此方法后限制从类外部访问给定方法.
$('div.myclass').live('click',function() {
alert('i should respond only once');
});
Run Code Online (Sandbox Code Playgroud)
我知道有一个one()jquery函数,但我无法想象如何将它与上面的代码集成.
例如,我有一个声明:
$var = '2*2-3+8'; //variable type is string
Run Code Online (Sandbox Code Playgroud)
如何使它平等9?
我知道我可以这样做system("color 1E"),但我很好奇是否有api调用可以做到这一点,因为这些更快,我需要为所有控制台着色color.我知道只有api调用,SetConsoleTextAttribute()但这只是在使用后写入的文本着色.
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
wstring my_str(L"El Niño ");
cout << my_str.find_last_not_of(L' ');
}
Run Code Online (Sandbox Code Playgroud)
此代码返回6但不应返回7?
我创建了一个简单的窗口:
CreateWindowExW(
WS_EX_TOPMOST,
L"RichEdit20W",
L"window_text",
WS_OVERLAPPEDWINDOW | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE //...
Run Code Online (Sandbox Code Playgroud)
现在,每当我焊割时间"窗口文本"参数,控制和窗口标题是变化的,同样有SetWindowTextW()和SendMessageW(hwnd, WM_SETTEXT, ...).