c++ - Proper way to implement Queue with MFC? -


what want is; store string values in text file in multi threaded environment. store each , every string values in queue , read queue step step , write values text file.

i saw example in msdn queues. example made changes , created code segment store cstring values.but can't achieve code.

class cqueue :public ctypedptrlist < coblist, cstring* > { public:     void addtoend(cstring* newlog) {         addtail(newlog);     }     cstring* getfromfront() {         return isempty() ? null : removehead();     } }; 

then try call this:

cqueue q; cstring str("data1"); q.addtoend(&str); 

it's give error:

'void coblist::addtail(coblist *)' : cannot convert argument 1 'atl::cstringt<wchar_t,strtraitmfc_dll<wchar_t,atl::chtraitscrt<wchar_t>>> ' 'cobject *' 

what best way implement queue in mfc ?

cstring no object or better: isn't derived cobject. said the list should derived coblist. have use cptrlist instead.

class cqueue :public ctypedptrlist < cptrlist, cstring* > 

please note: code dangerous. in sample create pointer variable exists on stack. if function exists pointer gets invalid...


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -