我试图在C ++中创建一个有序列表,但它并没有识别插入函数中的节点结构类型。很抱歉用英语命名一些变量,如testa和inserimento,它们都是head和input。
LISTA.CPP
// Note: I think sealed may be specific to Visual Studio Compiler.
// CRITICAL_SECTION is defined in Windows.h - If on another OS,
// look for similar structure.
class BlockThread sealed {
private:
CRITICAL_SECTION* m_pCriticalSection;
public:
explicit BlockThread( CRITICAL_SECTION& criticalSection );
~BlockThread();
private:
BlockThread( const BlockThread& c );
BlockThread& operator=( const BlockThread& c ); // Not Implement
};
BlockThread::BlockThread( CRITICAL_SECTION& criticalSection ) {
m_pCriticalSection = &criticalSection;
}
BlockThread::~BlockThread() {
LeaveCriticalSection( m_pCriticalSection
}
LISTA.H
#include "SomeClass.h"
#include "BlockThread.h"
static CRITICAL_SECTION s_criticalSection;
SomeClass::SomeClass {
// Do This First
InitializeCriticalSection( &s_criticalSection );
// Class Stuff Here
}
SomeClass::~SomeClass() {
// Class Stuff Here
// Do This Last
DeleteCriticalSection( &s_criticalSection );
}
// To Use The BlockThread
SomeClass::anyFunction() {
// When Your Condition Is Met & You Know This Is Critical
// Call This Before The Critical Computation Code.
BlockThread blockThread( s_criticalSection );
}
提前致谢
答案 0 :(得分:0)
不要向std
命名空间添加任何类或方法。它不适合你。
通常,insert()方法在实现对象列表时,会获取指向列表类实例的指针,而不是列表类的实例。
< / LI>您的insert()实现正在实现一个名为insert的函数,而不是Lista
类的方法,a.k.a Lista::insert()
。