sho*_*fee 1 c++ qt copy-constructor
当我的应用程序中调用此复制构造函数时,此复制构造函数进入无限循环,即它不断调用自身.当我调试在第一行终止的pogram时.使用的foreach循环是Qt foreach.
template<class TValue>
Locus<TValue>::Locus (const Locus<TValue>& source ) : QVector<TValue>(source) // program terminates here
{
std::cout << "calling self from here " << std::endl;
foreach (typename Locus<TValue>::value_type l, source)
{
this->push_back(l);
}
}
Run Code Online (Sandbox Code Playgroud)