我了解到我永远不能访问私有变量,只能使用类中的get函数.但是为什么我可以在复制构造函数中访问它?
例:
Field::Field(const Field& f)
{
pFirst = new T[f.capacity()];
pLast = pFirst + (f.pLast - f.pFirst);
pEnd = pFirst + (f.pEnd - f.pFirst);
std::copy(f.pFirst, f.pLast, pFirst);
}
Run Code Online (Sandbox Code Playgroud)
我的声明:
private:
T *pFirst,*pLast,*pEnd;
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的googlemaps v2功能移植到v3.
但不知怎的,我陷入了一个奇怪的错误,我无法找到,我做错了什么.
错误:未捕获的InvalidValueError:setPosition:不是LatLng或LatLngLiteral:在属性lat中:不是数字%7Bmain,adsense,geometry,zombie%7D.js:25
这里我的地图初始化:
var map = new google.maps.Map(document.getElementById("map"),{
zoom:4
size:new google.maps.Size(580,440),
mapTypeControl: true,
mapTypeControlOptions: {
style:google.maps.MapTypeControlStyle.VERTICAL_BAR,
position: google.maps.ControlPosition.BOTTOM_CENTER,
},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.TOP_LEFT,
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.LEFT_CENTER,
},
scaleConrol: true,
scaleControlOptions:{
position: google.maps.ControlPosition.TOP_LEFT ,
},
});
map.setCenter(new google.maps.LatLng(49.477643, 9.316406));
Run Code Online (Sandbox Code Playgroud)
这里是我的错误的部分:
function drawTraders(map, options) {
var traders_uri = options.traders_uri || '';
if ('' == traders_uri) {
return false;
}
// get the informations
$.getJSON(traders_uri, function(data) {
// look through the information
$.each(data.traders, …Run Code Online (Sandbox Code Playgroud) 我和我的团队正在合作一个项目.我的工作是为嵌入式系统创建一个带有QML和C++的Gui.
我为每个View都有一个qml文件.
但现在我想在它们之间导航.这意味着当我点击按钮时,视图应该切换.每个视图都有一个后退按钮,所以我可以回到我的主视图.
这可能在qml中吗?如果不是我必须用c ++解决它
我在Gentoo Linux上的Makefile有问题。
这是我的文件夹层次结构:
Development
-> GLTools
-> include
-> src
->Triangle
->triangle.cpp
->Makefile
Run Code Online (Sandbox Code Playgroud)
和我的Makefile:
MAIN = triangle
SRCPATH = ./
SHAREDPATH = ../GLTools/src/
SHAREDINCPATH = ../GLTools/include/
LIBDIRS = -L/usr/local/lib
INCDIRS = -I/usr/include -I/usr/local/include -I/usr/include/GL \
-I$(SHAREDINCPATH) -I$(SHAREDINCPATH)GL
CC = g++
CFLAGS = $(COMPILERFLAGS) -g $(INCDIRS)
LIBS = -lglut -lGL -lGLU -lm
prog : $(MAIN)
$(MAIN).o : $(SRCPATH)$(MAIN).cpp
glew.o : $(SHAREDPATH)glew.c
GLTools.o : $(SHAREDPATH)GLTools.cpp
GLBatch.o : $(SHAREDPATH)GLBatch.cpp
GLTriangleBatch.o : $(SHAREDPATH)GLTriangleBatch.cpp
GLShaderManager.o : $(SHAREDPATH)GLShaderManager.cpp
math3d.o : $(SHAREDPATH)math3d.cpp
$(MAIN) : $(MAIN).o glew.o
$(CC) …Run Code Online (Sandbox Code Playgroud) 我正在使用gcc 4.6.2.
我正在尝试在向量shared_ptr中推送back_back.
但gcc每次都给我一个错误.
这是我的代码行:
std::vector< std::tr1::shared_ptr<Process> > procs;
std::string line;
while (getline(file, line) && line.find(JobMask) != std::string::npos)
{
std::string procName = line.substr(line.find(JobMask) + JobMask.size());
std::vector<Instruction> procInstructions = extractProgram(file);
std::queue<int> procInputs = extractInputs(file);
if (!procInstructions.empty())
procs.push_back(std::make_shared<Process>(Process(procName, procInputs, procInstructions))); //line 51
}
return procs;
Run Code Online (Sandbox Code Playgroud)
我的gcc给出的错误是:
Process.cpp: In static member function 'static std::vector<std::tr1::shared_ptr<RMMIX::Process> > RMMIX::Process::createProcesses(const string&)':
Process.cpp:51:95: error: no matching function for call to 'std::vector<std::tr1::shared_ptr<RMMIX::Process> >::push_back(std::shared_ptr<RMMIX::Process>)'
Process.cpp:51:95: note: candidates are:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/include/g++-v4/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::tr1::shared_ptr<RMMIX::Process>, _Alloc = …Run Code Online (Sandbox Code Playgroud) 我的根文件夹结构是这样的:
My Family - Holiday My Birthday[15.11] Name-Name[1] Name1 Name2 ...
现在,我希望包含.info文件的每个文件夹都移动到另一个目录.
这是我的代码:
#!/bin/sh
for folder in *
do
echo $folder
if [ -e "$folder/*.info" ]
then
echo $folder
mv $folder ./Finished
fi
done
Run Code Online (Sandbox Code Playgroud)
回声仅用于测试.我发现每次非转义字符都在名称中if失败.我怎样才能解决这个问题?
我正在尝试解析一个html文件并提取一些信息并对其进行统计.
但我的问题是,HTML :: TreeBuilder只返回1个结果,但我需要正则表达式捕获的所有结果.
#!/bin/perl
use strict;
use warnings;
use Data::Dumper;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new();
$tree->parse_file('tester.html');
print Dumper($tree->look_down(_tag => 'table',id => qr{post[0-9]*?})->as_HTML);
$tree->delete;
Run Code Online (Sandbox Code Playgroud)
tester.html:
<table id="post923076">
<tr>
<td>table1_result</td>
</tr>
</table>
<table id="post923076">
<tr>
<td>table2_result</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我的结果:
$VAR1 = '<table id="post923076"><tr><td>table1_result</td></tr></table>';
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?
我缩短了文件,例如因为该文件可以满足很多这样的表格.
我想知道,如果有另一种方法来读出一个大文件
Hans //name
Bachelor // study_path
WS10_11 //semester
22 // age
Run Code Online (Sandbox Code Playgroud)
而不是这样的:
fout >> name; //string
fout >> study_path; //string
fout >> Semester ; //string
fout >> age; //int
Run Code Online (Sandbox Code Playgroud)
当我的文件变成超过20行时,我应该制作20多个fouts?
还有另外一种方法吗?
c++ ×4
c++11 ×1
gcc4 ×1
html-parsing ×1
javascript ×1
linux ×1
make-shared ×1
makefile ×1
perl ×1
private ×1
qml ×1
qt ×1
shared-ptr ×1
shell ×1
unix ×1