serialization of template class problem

Hi there,

I recently wrote a simple template class named "matrix". This matrix
can hold double, int data types via

template <class TT>
matrix<TT> :: matrix(int d1, int d2);

The problem comes when I try to implement serilization as follows:

template <class TT>
IMPLEMENT_SERIAL(matrix<TT>, CObject, 1);

error C2955: 'matrix' : use of class template requires template
argument list
        c:\program files\vulcan\ta_matrix.h(26) : see declaration of
'matrix'

Could anybody help me? Thanks.
0
XinMengYu (4)
7/15/2008 12:15:59 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
586 Views

Similar Articles

[PageSpeed] 14

SimonYu wrote:
> Hi there,
> 
> I recently wrote a simple template class named "matrix". This matrix
> can hold double, int data types via
> 
> template <class TT>
> matrix<TT> :: matrix(int d1, int d2);
> 
> The problem comes when I try to implement serilization as follows:
> 
> template <class TT>
> IMPLEMENT_SERIAL(matrix<TT>, CObject, 1);
> 
> error C2955: 'matrix' : use of class template requires template
> argument list
>         c:\program files\vulcan\ta_matrix.h(26) : see declaration of
> 'matrix'
> 
> Could anybody help me? Thanks.

SimonYu:

I am not sure if it possible to serialize a template class, but I would advise 
you to avoid MFC binary serialization.

Use XML instead. Even Microsoft Office does this now.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
7/15/2008 12:41:50 PM
On Jul 15, 1:41=A0pm, David Wilkinson <no-re...@effisols.com> wrote:
> SimonYu wrote:
> > Hi there,
>
> > I recently wrote a simple template class named "matrix". This matrix
> > can hold double, int data types via
>
> > template <class TT>
> > matrix<TT> :: matrix(int d1, int d2);
>
> > The problem comes when I try to implement serilization as follows:
>
> > template <class TT>
> > IMPLEMENT_SERIAL(matrix<TT>, CObject, 1);
>
> > error C2955: 'matrix' : use of class template requires template
> > argument list
> > =A0 =A0 =A0 =A0 c:\program files\vulcan\ta_matrix.h(26) : see declarati=
on of
> > 'matrix'
>
> > Could anybody help me? Thanks.
>
> SimonYu:
>
> I am not sure if it possible to serialize a template class, but I would a=
dvise
> you to avoid MFC binary serialization.
>
> Use XML instead. Even Microsoft Office does this now.
>
> --
> David Wilkinson
> Visual C++ MVP- Hide quoted text -
>
> - Show quoted text -

Thank you David!
Unfortunately, I have to use binary serialization in accordance with
other codes which has been developed by others.
0
XinMengYu (4)
7/15/2008 3:10:13 PM
SimonYu wrote:
> Thank you David!
> Unfortunately, I have to use binary serialization in accordance with
> other codes which has been developed by others.

Simon:

Do you really need to make your matrix class derive from CObject and be itself 
serializable? For the purpose of serialization can you not place your matrix 
inside another class?

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
7/15/2008 6:23:07 PM
On Jul 15, 7:23=A0pm, David Wilkinson <no-re...@effisols.com> wrote:
> SimonYu wrote:
> > Thank you David!
> > Unfortunately, I have to use binary serialization in accordance with
> > other codes which has been developed by others.
>
> Simon:
>
> Do you really need to make your matrix class derive from CObject and be i=
tself
> serializable? For the purpose of serialization can you not place your mat=
rix
> inside another class?
>
> --
> David Wilkinson
> Visual C++ MVP

Dear David,

It is a good idea to serialize the matrix outside the matrix class. It
is a bit troublesome to write serialization codes in all the classes
wherever I implement the matrix class. Alternatively, should I forget
the template ?

Simon
0
XinMengYu (4)
7/15/2008 10:35:45 PM
On Jul 15, 11:35=A0pm, SimonYu <XinMen...@gmail.com> wrote:
> On Jul 15, 7:23=A0pm, David Wilkinson <no-re...@effisols.com> wrote:
>
> > SimonYu wrote:
> > > Thank you David!
> > > Unfortunately, I have to use binary serialization in accordance with
> > > other codes which has been developed by others.
>
> > Simon:
>
> > Do you really need to make your matrix class derive from CObject and be=
 itself
> > serializable? For the purpose of serialization can you not place your m=
atrix
> > inside another class?
>
> > --
> > David Wilkinson
> > Visual C++ MVP
>
> Dear David,
>
> It is a good idea to serialize the matrix outside the matrix class. It
> is a bit troublesome to write serialization codes in all the classes
> wherever I implement the matrix class. Alternatively, should I forget
> the template ?
>
> Simon

No, the matrix can be a basic class and not necessary to derive from
CObject.
0
XinMengYu (4)
7/15/2008 10:54:19 PM
Reply:

Similar Artilces:

Weird Problem With Office 2004 on Tiger 10.4.1
Here's the readers digest version of the problem. A friend just went from 9.2.2 to Tiger yesterday and when he tried to install the Office 2004 upgrade, it said that his product key was not correct. A phone call to Microsoft confirmed that the key was actually valid and there was some issue with his system. I tried the same CD on another system with the same key and it worked, so it would appear they are correct. I took a full version of Office 2004 and it installed fine. However, none of the apps will start. The icons will bounce for a bit and then stop bouncing. No error messages get di...

Calendar Template
In my job at a law firm, we deal with a lot of calendaring. However, most cases proceed on a set schedule with certain hearings and deadlines (ie. pretrial conference on ____, witness list due on _____, etc). Is there any way that I can create a template in my Outlook Calendar so that I can just add the case name and the due date without having to type out the entire entry everytime? Depending on the type of case, there are between 12 and 20 entries per case. Do you need one calendar item with the schedule in the body or the ability to enter the data one and create appointme...

keyboard event handle problem!
hi all.. in my application i did handling to keyboard using preTranslateMsg because my application is dialog based. i called onKeyUp & onKeyDown inside it to get the necessary parameters cause i want to send them over network.. i also used Keybd_event. but when i integrated it in my application that handles the mouse too using ordinary mouse msgs from the class wizard i have problems in controlling the application. i can`t control the mouse move any more. what`s the problem? The question is too confusing to answer. You don't call OnKeyUp and OnKeyDown; the framework calls them for y...

Asynchronous HTTP class
I'm using VC++ 6.0, and I've heard bad things about WinInet in asynchronous mode. Specifically, that it isn't reliable. Is there another class I can use that would relieve me from having to worry about HTTP intricacies? You can use async socket classes of MFC e.g. Arkady "Jo" <JoJoTwilligo@hotmail.com> wrote in message news:1135017765.129844.315230@g14g2000cwa.googlegroups.com... > I'm using VC++ 6.0, and I've heard bad things about WinInet in > asynchronous mode. Specifically, that it isn't reliable. Is there > another class I can use that ...

Strangest Problem Ever
I will try to be as clear as possible here. I am using Outlook 2002. (thats clear so far!)..I have 2 different Email profiles. One for me, one for my wife. It was working fine. All of the sudden, her account won't send/receive. I get an 0x8 error saying the pop server couldnt be found. All the settings are correct. Now for the tricky part. I switch to my profile, and everything works fine. In addition, I add her info as another address in MY profile and it works fine again! Then I switch to her profile and no dice! Am I still clear? Any help is appreciated! Steve Try creating a...

Problem 02-01-08
Ive got gmail(google mail) and ive thried to use pop3 be in vista on outlook express it don't work help!! Hi Jamie, This newsgroup is dedicated to the Microsoft Access database product. The Microsoft website is not all that clear and may have misdirected you. I suggest post your question to the applicable Vista newsgroups available below: Windows Vista discussion groups: http://windowshelp.microsoft.com/communities/newsgroups/en-us/default.mspx Tom Wickerath Microsoft Access MVP http://www.accessmvp.com/TWickerath/ http://www.access.qbuilt.com/html/expert_contributors.html ______...

Pivot Table Template #2
Thank you for reviewing this! I have created a pivot table/chart workbook that I need to save as a template. The source data is local without any external links. However, when I save the workbook as a template file, it asks the following question regarding external data: "This workbook contains external data. Do you want MS Office Excel to clear the data before saving the template, and then automatically refresh the data whenever the template is opened?" Is this standard XL logic for a pivot table template even when external data is not present and is there a way to no...

Importing 2003 Chart Templates into 2007
I have custom charts (bars and lines). They open in 2007 as only bars. How do I save/copy the 2003 templates (from my old computer) so my charts work? Also, my Excel macros don't appear to work. I downloaded the 2003/2007 conversion patch already (w/o success). Thanks. Hi, I don't believe that the Custom Type templates that were available in 2003 are available in 2007 although you could make your own and then save them to the Templates folder in the Insert, Charts, Manage Templates area. Regarding your 2003 files coming in to 2007 without the line on a column/line chart, ...

Serial Number Problem
Hi Everyone, we run Dynamics on our server anyway we had HUGE problems and lost a lot of work.....anyway after fixing lots up i still have one MAJOR problem. Serial numbers for items in the system do exist if you look up inventory ~ Serials. There is a list of serial numbers in stock ready to use. But when we go to do an invoice there are no serial numbers, it asks you if you want to overide the quantities... Our problem was we lost our inventory file therefore we had to put an old file back on...although these serial numbers are there we can not use them which also means i cant put t...

Double signature in 2007 template
Hi, I have been using Outlook 2007 templates for a year and a half now at work. Starting yesterday, after about 30+ Window updates, there are double signatures when I open a new template (Tools > Forms > Choose a Form > User Templates in File System). Has anyone else had this problem? See the thread titled Duplicate Signatures from 1/20/2010 SWSprWmn wrote: > Hi, > > I have been using Outlook 2007 templates for a year and a half now at work. > Starting yesterday, after about 30+ Window updates, there are double > signatures when I open...

For Each Next problem
I am embarrassed to say I have never been able to get an each, next to work...probably due to my learn by problem method instead of an organized class but I am hoping that by conquering this one, I will finally get it. I need to send an email to each of the people returned by an query. I created a form with the email info and a button for sending it, which works fine for the first record but none of the others. Here is the code I wrote for the cmd button...what am I doing wrong??? Private Sub cmdSend_Click() Dim ctl As Control Dim rst As Recordset ctl = [txtEmail] ...

Problem on an IF formula
Hi, IF(B853-(B854+B855)<>0,B853-(B854+B855),"") here it with the cell values instead of cell address: IF ( 83.80 - ( 40.45 + 43.35 ) <> 0, 83.80 - (40.45 + 43.35), "" ) --The problem is that on the condition : IF ( 83.80 - ( 40.45 + 43.35 ) <> 0, --> Excel is giving me a TRUE result. Shouldn't this condition produce a False result?? Excel then proceeds to do the arithmetic with a value of -1.4219E -14 The values of these 3 cells have been checked many times, and they are all typed exactly to 2 decimal places. Any thoughts? try this ...

CListCtrl problem.
Well I just started playing with VC++ yesterday, so keep it simple if you can. thx. Anyway, I'm having problems with a CListCtrl in report view. The first column seems to display fine, but the other columns don't. Have a look at my function for adding data: void CMP3RenamerDlg::PopulateList(CString str) { CFileFind finder; LVITEM lvi; CString item; CString strWildcard(str); strWildcard += _T("\\*.mp3"); BOOL bWorking = finder.FindFile(strWildcard); int i = 0; while (bWorking) { bWorking = finder.FindNextFile(); if (finder.IsDots()) continue; // Populat...

Display Problems with Overlapping MFC Controls Each with OpenGL graphics
I have followed the general procedure laid out in "Setting Up OpenGL in an MFC Control" at "http://www.codeguru.com/Cpp/Cpp/cpp_mfc/ tutorials/article.php/c10975" to create a base graphics class, so for the most part, the structure of code located there is the base I'm working from with several of my own modifications. >From there, I have then created two graphing classes (2d and 3d) that each inherit from this base class and have been using them without problems in their own MFC dialog windows. I wanted to create a combined graphics application/dialog capable of u...

Duplicate Element Names in Serialized XML
Hi All, Hoping someone can solve a problem for me. I am modifying the schema for a rather complex web service written in VB.NET. The services uses a large number of serialized classes to output the overall XML. The problem I am having is that I require 2 XML elements of the same name to be serialized from the 1 class. Due to the way the web service is written only 1 of these would be ever be called at a time. However, it seems that I get an exception if the same element name is used twice in one class.. any ideas? For example: 'start class here <XMLElement ("elementName&q...

How do I prepare a template with default line thickness for boxes?
I am using Publisher2000. I have designed a template with some text formatting attributes. Now I want to include a default “thin line thickness” when I use the drawing tool for drawing a rectangle on the page. Regards Jorgen From Help 1. On the Objects toolbar, click the tool that creates the type of frame or object you want to set the default formats for. Do not create an object at this point; just click the tool and go on to step 2. 2. Choose the commands, dialog box options, or toolbar buttons for the formatting you want. Now each time you use this tool in the current publication, th...

Serial Motor
How do you control a motor via serial port? What language should I use? Justin Case wrote: > How do you control a motor via serial port? What language should I > use? I don't know, but it certainly isn't possible with SQL Server ... http://lmgtfy.com/?q=How+do+you+control+a+motor+via+serial+port -- HTH, Bob Barrows Bob Barrows (reb01501@NOyahoo.SPAMcom) writes: > I don't know, but it certainly isn't possible with SQL Server ... What? You can't control a motor with an engine? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se...

serial port communuication
Hi all, I m communicating to a printer device through serial port.It is failing to open the port,but when I disable and enable the com port in device manager,it works fine(i.e)it communicates with the printer and reads the configuration settings of the printer). Regards Hari are u leaving the port opened when ur program terminates ........ what is the frequency of u disabling/enabling port ....... after every run ...... some times works some times not ..... ????? "hari" <haricibi83@gmail.com> wrote in message news:1171455246.402743.203120@k78g2000cwa.googlegrou...

Printing Problem.
What causes the left margin to be "chopped off" when printing emails from Outlook Express? How can I fix it? "Teddi" <anonymous@discussions.microsoft.com> wrote in message news:001601c3dea7$51751c40$a301280a@phx.gbl... > What causes the left margin to be "chopped off" when > printing emails from Outlook Express? How can I fix it? Why do you need to print emails in the first place? This newsgroup is for support of Outlook 97/98/2000/2002/2003 from the Office suite of products. Outlook Express is actually a separate program despite the similar nam...

Inserting Rows Problem
Hi there, I have a list of about 2000 rows. However, in between each of thes rows I want to insert a blank row that can be used for people to writ in once the list is printed off. Is there a quick way to do this? Kind regards Andre -- andyp16 ----------------------------------------------------------------------- andyp161's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1165 View this thread: http://www.excelforum.com/showthread.php?threadid=26611 If you insert rows it will affect sorting, etc. and be a real pain. Many posts here want to delete blank rows ...

Calendar template in Publisher
Can I create my own calendar template in Publisher? ...

Serialization of jagged Arrays Issue
Hi there, I m trying to return an object (of my own written class) from a web service that contains jagged Arrays as public variables. Asp.Net is showing me the its serialized version on the browser when i invoke the service during test. Code: public class returnType { [System.Xml.Serialization.XmlElementAttribute("chassisdata")] public _chassisdata[] chassisdata; [XmlArray(),XmlArrayItem("wheel", typeof(_wheel[]),IsNullable=false)] public _wheel[][] upsteps; [XmlArray(),XmlArrayItem("wheelsize", typeof(_wheelsize[]),IsNullable=false)] publi...

Problem Sorting
If I put [DBNum]*1000+[Inst Num] in the Sorting and Grouping box, it sorts correctly. The value of: [Forms]![boxSeats]![SortBy] can be 1 or 2. I want to sort by [BankName] if 1. I want to sort by [DBNum]*1000+[Inst Num] if 2. I am putting the following in the Sorting and Grouping box, (this doesn't sort properly): =IIf([Forms]![boxSeats]![SortBy]=1,[BankName],[DBNum]*1000+[Inst Num]) When "SortBy" is 1, it sorts okay. When "SortBy" is 2, it DOES NOT sort properly. Can someone suggest what I'm doing wrong? Thanks for the reply. I am getting a syntax ...

mapi problem
got a new pc win xp pro and it had a preloaded trial version office 2003 s&t with outlook 2003 setup as mail and editor in oe. I uninstalled the program and installed works suite 2004. but works programs cannot send mail. oe sends and receives mail. second spybot bug reporter on send says no mapi on system. hence the uninstall removed something. does anyone know what and how to get mapi back. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.707 / Virus Database: 463 - Release Date: 6/15/2004 >-----Original Mes...

open files serially
Hi, I seek your help for the following; I have few files in one of the folder. The file names are ending with numeric number. The uniqueness of the file names are they are serially numbered e.g. ABC123.xls, XYZ124.xls, MNO_AB125.xls, LKM126.xls. I would like to open these files serially (...123 then ...124 so on so forth till last files in the folder). Once the file is open i would like to do some processing and save it in another folder. The files once opened and saved in another folder it should get deleted from earlier folder (From where the file was opened). Than...