Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta17-Jun-08 22:28
Trupti Mehta17-Jun-08 22:28 
GeneralRe: Problem Reading/Writing text/dat files Pin
Mark Salsbery18-Jun-08 6:13
Mark Salsbery18-Jun-08 6:13 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta18-Jun-08 22:57
Trupti Mehta18-Jun-08 22:57 
GeneralRe: Problem Reading/Writing text/dat files Pin
Mark Salsbery18-Jun-08 9:12
Mark Salsbery18-Jun-08 9:12 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta18-Jun-08 22:44
Trupti Mehta18-Jun-08 22:44 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta19-Jun-08 0:15
Trupti Mehta19-Jun-08 0:15 
GeneralRe: Problem Reading/Writing text/dat files Pin
Mark Salsbery19-Jun-08 6:04
Mark Salsbery19-Jun-08 6:04 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta19-Jun-08 22:38
Trupti Mehta19-Jun-08 22:38 
Mark, I also have added in the same file (DbOperations.cpp) just copied your code same way. All serialization.desera & template overrride are in the same file. I tried removing template<> & AFXAPI, but still no success.

You were very correct that with pointers of Map I will have a problem. To pass the DbOperations reference to other classes, I made a copy constructor & operator=, in this case I can't directly copy map tp map. So I made operatorMap as pointer & the other map deptMap is as a normal object only & not assigning in copy constru or =. deptMap additions & updations are possible (NOT a pointer), but operatorMap (a POINTER) operations are not allowed. It causes Assertion failure in afxtempl.h line 1368 which is Assert 1st line of CMap<> operator[].

I got to take out some solution of this. Can you tell how to assign a map to map in copy constructr & = operator. Basically copy a map to other. In DbOperations .h
typedef CMap<int, int, OperatorDetails, OperatorDetails&> OperatorDetailsMap;
typedef CMap<int, int, DeptDetails, DeptDetails&> DeptDetailsMap;

class ....{
	// MAPS
	OperatorDetailsMap* operMap;
	DeptDetailsMap deptMap;

In .cpp
// Copy Constructor
DbOperations::DbOperations(const DbOperations &d) {
	this->operMap = d.operMap;
//	this->deptMap = d.deptMap;
}
// = Assignment operator
DbOperations& DbOperations::operator=(const DbOperations &d) {
	this->operMap = d.operMap;
//	this->deptMap = d.deptMap;

	return *this;
}
/*template <> void AFXAPI SerializeElements <OperatorDetails> (CArchive &ar, OperatorDetails *pOperatorDetails, INT_PTR nCount){
	for (int i = 0; i < nCount; i++, pOperatorDetails++)	{
		pOperatorDetails->Serialize(ar);
	}
}*/


My point is how do I copy this.deptMap with d.deptMap, where deptMap being normal objects & not a pointer. With this solution we wont have problem with serializeElements() & pointers. As SerializeElements() causes problems, so looking out for solution without serializeElements & pointers. SerializeElemtsis added only in DbOperations along with WriteArchive & ReadArchive. The same thing is working with Visual Studio, but not with eVC++4. Really it is difficult to code in eVC++ than VC++, many restrictions & uncompatibility.

Looking for solution as soon as possible. From days I have been looking for this solution & yet not solved. You have been extremely helpful throughout. I highly appreciate your help and look towards more help.

Thanks

Terry

AnswerRe: Problem Reading/Writing text/dat files Pin
ThatsAlok17-Jun-08 16:45
ThatsAlok17-Jun-08 16:45 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta17-Jun-08 22:33
Trupti Mehta17-Jun-08 22:33 
GeneralRe: Problem Reading/Writing text/dat files Pin
ThatsAlok18-Jun-08 5:15
ThatsAlok18-Jun-08 5:15 
GeneralRe: Problem Reading/Writing text/dat files Pin
Trupti Mehta18-Jun-08 22:48
Trupti Mehta18-Jun-08 22:48 
Questiona error about c++ read xml Pin
huke198716-Jun-08 21:31
huke198716-Jun-08 21:31 
GeneralRe: a error about c++ read xml Pin
huke198716-Jun-08 22:01
huke198716-Jun-08 22:01 
GeneralRe: a error about c++ read xml Pin
ThatsAlok17-Jun-08 20:55
ThatsAlok17-Jun-08 20:55 
AnswerRe: a error about c++ read xml Pin
Naveen16-Jun-08 22:37
Naveen16-Jun-08 22:37 
GeneralRe: a error about c++ read xml Pin
huke198716-Jun-08 22:58
huke198716-Jun-08 22:58 
GeneralRe: a error about c++ read xml Pin
Naveen16-Jun-08 23:11
Naveen16-Jun-08 23:11 
GeneralRe: a error about c++ read xml Pin
huke198716-Jun-08 23:33
huke198716-Jun-08 23:33 
GeneralRe: a error about c++ read xml Pin
Naveen16-Jun-08 23:37
Naveen16-Jun-08 23:37 
GeneralRe: a error about c++ read xml Pin
ThatsAlok17-Jun-08 2:06
ThatsAlok17-Jun-08 2:06 
GeneralRe: a error about c++ read xml Pin
kakan17-Jun-08 2:53
professionalkakan17-Jun-08 2:53 
GeneralRe: a error about c++ read xml Pin
huke198717-Jun-08 14:25
huke198717-Jun-08 14:25 
GeneralRe: a error about c++ read xml Pin
Stephen Hewitt17-Jun-08 18:23
Stephen Hewitt17-Jun-08 18:23 
GeneralRe: a error about c++ read xml Pin
Naveen17-Jun-08 19:01
Naveen17-Jun-08 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.