好的,我只是第一次学习模板,所以我在玩弄创建我自己的模板类,模仿它的基础类型是一个向量.请记住,对push_back的调用只调用底层向量的push_back方法.
vector<string> sV;
sV.push_back("ha"); //ok: converts from const char[3] to string
Foo<string> fS;
fS.push_back("ha"); //error: const char[3] does not match the argument list
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题?我只是希望我的模板感觉自然就像我正在使用真实的东西一样.
编辑:这基本上是班级的主体
template <typename T> class FooPtr;
template <typename T>
class Foo{
friend class FooPtr<T>;
public:
Foo() {data->make_shared(vector<T>); }
#ifdef INITIALIZER_LIST
Foo(initializer_list<T>);
#endif
void push_back(T &t) { data->push_back(t); }
void push_back(T &&t) { data->push_back(move(t)); }
bool empty() { if (data->size() == 0) return true; }
FooPtr<T> insert(size_t, T&);
T& operator[](size_t);
T& front();
T& back();
FooPtr<T> begin() { …Run Code Online (Sandbox Code Playgroud) 很抱歉,如果这是一个重复的问题,但我已经尝试寻找答案,空手而归。因此,基本上我只想在向量的后面添加字符串(单个单词),然后将存储的字符串显示为单个字符串。我真是个菜鸟。
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
using namespace std;
int main(int a, char* b [])
{
vector<string> userString;
string word;
string sentence = "";
for (decltype(userString.size()) i = 0; i <= userString.size() - 1; i++)
{
cin >> word;
userString.push_back(word);
sentence += userString[i] + " ";
}
cout << sentence;
system("PAUSE");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么不起作用?
编辑
int main(int a, char* b [])
{
cout << "Enter a sequence of words. Enter '.' \n";
vector<string> userString;
string word; …Run Code Online (Sandbox Code Playgroud) 好的,我正在制作有关 webRTC 的教程,并且我一直在使用以下两个教程来帮助我。
首先要注意的是,对于第一个教程,即使使用从 github 克隆的源代码:
https://github.com/sitepoint-editors/simplewebrtc-messenger.git
当我在 Now.sh 上部署应用程序时,它可以工作,但我无法加入不同的用户。
太长了;
这是我部署的应用程序。当我尝试加入远程连接时出现此错误
未捕获的 DOMException:无法构造“RTCPeerConnection”:“stun.l.google.com”不是受支持的 URL 方案“stun”、“turn”或“turns”之一。
这是[源代码
// Code goes here
let username, roomname;
// Determine whether or not we have a querystring.
function hasQueryString() {
console.log(location.href.indexOf("?"))
return location.href.indexOf("?") !== -1;
}
const formEl = $('.form');
// Enable video on the page.
function enableVideo() {
document.getElementById("url").style.display = "block";
document.getElementById("remotes").style.visibility = "visible";
loadSimpleWebRTC();
}
if (hasQueryString()) {
console.log("Query string!");
enableVideo();
if (formEl) {
formEl.hide(); …Run Code Online (Sandbox Code Playgroud)javascript video-capture video-streaming webrtc simplewebrtc