我有一个B类,我想把成员称为A类.所以:
1.
//A.h
class B;
class A
{
private:
B* m_p;
};
//a.cpp
#include "B.h"
Run Code Online (Sandbox Code Playgroud)
2.
// A.h
#include "B.h"
class A
{
private:
B * impl_;
};
Run Code Online (Sandbox Code Playgroud)
当一个没有太多依赖性的小项目涉及时,这两种方式是否更好?
我在Qt项目的几行代码上每1秒附加到Qvector.我注意到在STL deque中可以更好地在向量中添加一个新元素.什么是等效或类似的Qt方式?因为我在Qt库中找不到任何内容.
胡里奥
我有一个在dlib中定义的colume向量.我怎样才能将它转换为std :: vector?
typedef dlib::matrix<double,0,1> column_vector;
column_vector starting_point(4);
starting_point = 1,2,3,4;
std::vector x = ??
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一段来自openCL内核的代码.
const uint idz = 100;
const uint idy = 100;
unit4 size_sino;
uint idz_p;
uint idy_p;
idz_p = (idz*size_sino.y+idy)/16;
idy_p = fmod((idz*size_sino.y+idy), (uint)16);
Run Code Online (Sandbox Code Playgroud)
当我编译内核时,发生了一些错误:
:192:18: error: call to 'fmod' is ambiguous
<stdin>:1078:48: note: candidate function
<stdin>:1084:49: note: candidate function
<stdin>:1079:49: note: candidate function
<stdin>:1080:49: note: candidate function
<stdin>:1081:49: note: candidate function
<stdin>:1082:49: note: candidate function
<stdin>:1083:50: note: candidate function
<stdin>:1085:50: note: candidate function
<stdin>:1086:50: note: candidate function
<stdin>:1087:50: note: candidate function
<stdin>:1088:50: note: candidate function
<stdin>:1089:51: note: candidate function …Run Code Online (Sandbox Code Playgroud) 这里有一些代码我想在字符串中找到所需的子字符串块:
#include <algorithm>
#include <string>
using namespace std;
...
unsigned int stage = 3;
string::iterator iter = s.begin();
string::iterator iter_next = s.end();
for (unsigned int i=0; i<stage; i++) {
iter = std::find(iter, s.end(),"#STAGE");
}
iter_next = std::find(iter, s.end(), "#STAGE");
string sub = string(iter, iter_next);
...
Run Code Online (Sandbox Code Playgroud)
我选择返回迭代器而不是索引.但是,调试给我这个:
error: ISO C++ forbids comparison between pointer and integer.
c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\include\c++\bits\stl_algo.h:-1:
In function '_RandomAccessIterator std::__find(_RandomAccessIterator, _RandomAccessIterator,
const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >, _Tp = char [7]]':
c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\include\c++\bits\stl_algo.h:4224: instantiated
from …Run Code Online (Sandbox Code Playgroud)