template class operator friend functions - UPDATE [1/1]

This is a MIME message

--=_Turnpike_LdoN4xAq3LZ$MyPn=
Content-Type: text/plain;charset=us-ascii;format=flowed

Hello,

I am still having problems with operator friend functions in class 
templates and I have created a small code fragment to demonstrate the 
problem.

You can either just read it or better still add it to your existing MFC 
project and compile it and have a look at the errors for yourself.

With the first template (which has only one 'class' parameter) there are 
no problems. But with the second template (which has an additional 'int' 
parameter) the code generates two errors.

I am using Visual C++ 5.X.


--=_Turnpike_LdoN4xAq3LZ$MyPn=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=template.cpp
Content-Description: template.cpp
Content-MD5: SJ68IRXgcnaJQUslm676pA==


#include "StdAfx.h"

//////////////////////////////////////////////////

class ExampleClass
{

public:

	ExampleClass();

	virtual ~ExampleClass();

protected:

private:

};

ExampleClass::ExampleClass()
{
	return;
}

// VIRTUAL
ExampleClass::~ExampleClass()
{
	return;
}

//////////////////////////////////////////////////

template<class GENERIC_DATA>
class ExampleTemplateOne
{

friend CArchive & operator >> (CArchive &,		 ExampleTemplateOne &);
friend CArchive & operator << (CArchive &, const ExampleTemplateOne &);

public:

	ExampleTemplateOne();

	virtual ~ExampleTemplateOne();

	//

	BOOL MemberFunction(CArchive &);

	//

	GENERIC_DATA m_aData;

protected:

private:

};

// FRIEND
template<class GENERIC_DATA>
CArchive & operator >> (CArchive & rSrc, ExampleTemplateOne<GENERIC_DATA> &=
 rDst)
{
	return(rSrc);
}

// FRIEND
template<class GENERIC_DATA>
CArchive & operator << (CArchive & rDst, const ExampleTemplateOne<GENERIC_D=
ATA> & rSrc)
{
	return(rDst);
}

//

template<class GENERIC_DATA>
ExampleTemplateOne<GENERIC_DATA>::ExampleTemplateOne()
{
	return;
}

// VIRTUAL
template<class GENERIC_DATA>
ExampleTemplateOne<GENERIC_DATA>::~ExampleTemplateOne()
{
	return;
}

// VIRTUAL
template<class GENERIC_DATA>
BOOL ExampleTemplateOne<GENERIC_DATA>::MemberFunction(CArchive & rArchive)
{
	return(TRUE);
}

//////////////////////////////////////////////////

template<class GENERIC_DATA, int GENERIC_GROW>
class ExampleTemplateTwo
{

friend CArchive & operator >> (CArchive &,		 ExampleTemplateTwo &);
friend CArchive & operator << (CArchive &, const ExampleTemplateTwo &);

public:

	ExampleTemplateTwo();

	virtual ~ExampleTemplateTwo();

	//

	BOOL MemberFunction(CArchive &);

	//

	GENERIC_DATA m_aData[GENERIC_GROW];

protected:

private:

};

// FRIEND
template<class GENERIC_DATA, int GENERIC_GROW>
CArchive & operator >> (CArchive & rSrc, ExampleTemplateTwo<GENERIC_DATA, G=
ENERIC_GROW> & rDst)
{
	return(rSrc);
}

// FRIEND
template<class GENERIC_DATA, int GENERIC_GROW>
CArchive & operator << (CArchive & rDst, const ExampleTemplateTwo<GENERIC_D=
ATA, GENERIC_GROW> & rSrc)
{
	return(rDst);
}

//

template<class GENERIC_DATA, int GENERIC_GROW>
ExampleTemplateTwo<GENERIC_DATA, GENERIC_GROW>::ExampleTemplateTwo()
{
	return;
}

// VIRTUAL
template<class GENERIC_DATA, int GENERIC_GROW>
ExampleTemplateTwo<GENERIC_DATA, GENERIC_GROW>::~ExampleTemplateTwo()
{
	return;
}

// VIRTUAL
template<class GENERIC_DATA, int GENERIC_GROW>
BOOL ExampleTemplateTwo<GENERIC_DATA, GENERIC_GROW>::MemberFunction(CArchiv=
e & rArchive)
{
	return(TRUE);
}

//////////////////////////////////////////////////

void ExampleFunction(CArchive & rArchive)
{
	////////////////////////
	// ExampleTemplateOne //
	////////////////////////

	ExampleTemplateOne<ExampleClass> typeOne;

	// OK
	//
	typeOne.MemberFunction(rArchive);

	// OK
	//
	rArchive >> typeOne;

	// OK
	//
	rArchive << typeOne;

	////////////////////////
	// ExampleTemplateTwo //
	////////////////////////

	ExampleTemplateTwo<ExampleClass, 32> typeTwo;

	// OK
	//
	typeTwo.MemberFunction(rArchive);

	// error C2679: binary '>>' : no operator defined which takes a right-hand=
 operand of type
	// 'class ExampleTemplateTwo<class ExampleClass,32>' (or there is no accep=
table conversion)
	//
	rArchive >> typeTwo;

	// error C2678: binary '<<' : no operator defined which takes a left-hand =
operand of type
	// 'class CArchive' (or there is no acceptable conversion)
	//
	rArchive << typeTwo;

	return;
}

--=_Turnpike_LdoN4xAq3LZ$MyPn=
Content-Type: text/plain;charset=us-ascii;format=flowed



Many thanks in advance!

Richard Moody

--=_Turnpike_LdoN4xAq3LZ$MyPn=--
0
9/14/2003 7:14:42 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
433 Views

Similar Articles

[PageSpeed] 28

Reply:

Similar Artilces:

Resource Update does not update location field
We have one person create a meeting request for a resource and some other users. Then if someone else goes and modifies the meeting request resource for the location, the location field does not update. But if the original creator does the same process, it works fine and does update the location field. ...

Why are my RSS Feeds not updating
I have three Microsoft feeds, one is Microsoft At Home , one is Microsoft At Work and the last is MSNBC News. They are in my subscribed feeds list but do not update as they do on my desktop. Are they still listed as subscribed when you go to; Tools-> Account Settings...-> RSS Feeds If so, removing them and then adding them back might help to revive them. You can also export the RSS Feeds to an OPML file, remove the subscriptions and then import the OPML file again. For details see; http://www.msoutlook.info/question/406 -- Robert Sparnaaij [MVP-Outlook] Coauthor, C...

Sending an Email(not template) in Workflow to a Contact
Hi, I am trying to figure out which Contact is used when you send an email in workflow without using the template. I know that if I select the Logical User Account then it uses the Email address field on the Account screen, but I cannot see or find which Contact email address is used when the Logical User Contact is used. I thought it might be the Primary Conact in the Account but it does not work. I get a Fail message in the Workflow Logs. <description> Activity party object type is invalid </description><file>d:big long file name.inl</file><line>2903>&l...

bitmap and dc inside a member function
I have a bitmap that is a class member. If, inside a class member function, I select the bitmap into a local device context, do I need to select the bitmap out of the dc before the dc goes out of scope? "Steve Russell" <srussell@innernet.net> wrote in message news:OYn8TcifDHA.392@TK2MSFTNGP12.phx.gbl... > I have a bitmap that is a class member. If, inside a class member function, > I select the bitmap into a local device context, do I need to select the > bitmap out of the dc before the dc goes out of scope? Yes. Jeff... Consider using CDC::SaveDC and CDC::Re...

what template should i use for collecting monthly payments from m.
...

how to update house value
How do I update the house value in money (04) without using an expense account in the transaction (for the difference)...or do you have to use one? And if you do, which one should it be?...but won't that throw out my income/expense reports? Thanks, LF On Jul 16, 2:25=A0am, LF <L...@discussions.microsoft.com> wrote: > How do I update the house value in money (04) without using an expense > account in the transaction (for the difference)...or do you have to use o= ne? > And if you do, which one should it be?...but won't that throw out my > income/expense reports? &...

Does any one ever use function capFileSaveDIB?
I use VS .NET 2003. I had connected to a USB camera. I tried to capture the image. The function capFileSaveDIB is used. MSDN said this function would return true if successful. I call the function like this: int cameraCapture(HWND hWndofCap, CString pathCStr) { char* pathStr = ""; strcpy(pathStr, pathCStr.GetBuffer()); pathCStr.ReleaseBuffer(); if (capFileSaveDIB(hWndofCap, pathStr)) return 1; else return 0; } I get the return value: 1. However, I don't get the picture where pathCStr pointed. I don't understand. Have you met this problem? I can't find out wh...

Enter/Tab not functioning
We have a customer who recently upgraded to GP v 10.0. They are having random issues with the User Preferences for the Tab/Enter key. On certain instances when the User logs into GP, he is unable to use either Tab or Enter to move through fields - he has to go into User Preferences and click OK - it lasts as long as he is logged in but on the next day, he has to repeat the process. Has anyone else experienced this type of issue? He reports that it is random and has happened to several users in GP. Thank you! ...

simple install instructions for CRM 1.2 installatio on SBS 2003
Hello, I have undertaken several attempts to run Microsoft CRM with the standard intranet functionalitie of SBS 2003. SBS 2003 with SP 1 and SQL SP4 is running well. In spite of several instructions by chapter 15 or this newsgroup will it not working. First some IIS and DNS errors and after that a login error. Is There someone who has an easy, clear and complete instruction guide? In advance thanks for your response, Jaap Hi this address may help you http://www.microsoft.com/technet/prodtechnol/mscrm/mscrm12/01_Intro.mspx Best Regards -- Göksal Ersen Çelebi Senior Softwar...

Count Only Weekday in the DateDiff Function
Hello, I have a report where the following function counts the interval of days between two dates. This is one of the actual formulas being used: =DateDiff("d",[to_plm],[from_plm]) Now, I need to adjust this syntex so that only the weekdays, workdays, are counted. Please help! -- phm http://lmgtfy.com/?q=access+work+day+function -- Duane Hookom Microsoft Access MVP "phm" wrote: > Hello, > I have a report where the following function counts the interval of days > between two dates. This is one of the actual formulas being used: &...

Reminding function in Team/Public Folder
Hello, at first I would like to know how these folders are officially called in English - Team Folder or Public Folders? Both searchstrings turn up results in Google. Lets me explain my problem: We are working with Outlook 2000 and Exchange 2000. Since some time we are using public folders. But we are missing one function. We want Exchange to send an email or Outlook popup to the users concerened on change, creation or maturity of a task or calendar entry in a public folder. It doesnt have to be Exchange, we could also implement a little tool at the client computers. Is this possible? Are the...

Obtaining More Relevant Templates #2
Dear All Does any one know where I can beg borrow or buy Publisher 2000 templates that are more relevant to the UK. Regards-- nebb Either you had asked this question about two weeks ago or you're asking the same thing. What "more UK relevant" items are you looking for? -- JoAnn Paules MVP Microsoft [Publisher] "nebb" <nebb(erase)@freenet.co.uk> wrote in message news:9976BC16-5B28-4161-B716-8252489F94A2@microsoft.com... > Dear All > Does any one know where I can beg borrow or buy Publisher 2000 templates > that are more relevant to the UK. > ...

Update linked formulas between workbooks
We have 2 workbooks where staff enter daily totals. The totals in these 2 worksbooks need to be combined for a grand total. I created a formula that adds Day 1 of workbook1 to Day 1 of workbook2. However, we must save both workbooks, and close/reopen the one with the formula to update the total. I tried using Edit/Links but that didn't work. Any suggestions? --- Message posted from http://www.ExcelForum.com/ Hi, Check that 'Update remote references' is checked un Tools|Options|Calculation. Cheers "lbabli" <lbabli.yke8y@excelforum-nospam.com> wrote in me...

Outlook Address Book not updating.
We run Exchange 2003 SP2 and have Outlook 2000 and 2003 users. The Outlook 2003 users that run in cached mode don't get an updated version of the OAB. If they are turned onto non cached mode they are fine. If we then turn them back to cached mode it uses and old OAB. I have tried to do a send and receive > download address book, but it doesn't update. I also renamed the the udetails.OAB file and it then downloaded this old OAB. I checked the server and it updates the OAB at 4am veryday. I can't even see anything in the Excahnge event log to say the OAB is been done...

1/3 A4 booklet template
Where can I find a 1/3 A4 size booklet templete? I want one that allows me to fold an A4 landscape sheet in three. Beemer What you want is a brochure. File, new, Publications for print, brochure. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Beemer" <Beemer@nowhere.com> wrote in message news:Od4Iqc$4HHA.1484@TK2MSFTNGP06.phx.gbl... > Where can I find a 1/3 A4 size booklet templete? I want one that allows me to > fold an A4 landscape sheet in three. > > Beemer > Mary, Thanks, Beemer &quo...

Recipient Address Template Changes
Nothing of major urgency, but just something that I cannot get to work ... I run SBS 2003 (with Exchange 2003). Go into System Manager - Recipients - Details Templates - English and double click User. Go to the Templates tab and click Test to see the currently used address template. Now let's say I want to make some minor changes to this such as changing Zip Code to Postcode, or changing Pager to Mobile, etc. I make the changes, then click Test to check all is ok. However, my clients who are running Outlook 2003 in cached exchange mode NEVER get these address template changes. You ...

Update dynamically appended MDI menu
I am trying to dynamically append a menu to MDI Doc/View's menu. Everything is ok except that the menu doesn't get refreshed till I move/minimize (etc.) the main App's window. Kindly suggest as to how to make it visible as soon as the child window gets visible. Seems AfxGetApp()->m_pMainWnd->UpdateWindow(); isn't working either :o( CMenu *pMainMenu = AfxGetApp()->m_pMainWnd->GetMenu(); // Assuming that we have a qualified CMenu object pointer // called 'pChildMenu', let's append it to the main menu: pMainMenu->AppendMenu(MF_STRING|MF_POPUP , (int...

Outlook xp updates won't install
I have been having a problem getting any updates for office xp. I got the following were unable to be installed: Security Update for Excel 2003 (KB905756) Update for Outlook 2003 Junk Email Filter (KB913161) Update for Outlook 2003 (KB913807) Any ideas as to why I suddenly can't get these to install? Have you restarted and then tried to reinstall them? -- Kathleen Orland Blessed are the cracked, for it is they who let in the light Outlook Tips: http://www.outlook-tips.net/ http://www.howto-outlook.com/ "Rick" wrote: > I have been having a problem getting any ...

Analog Tuner Function
I have an HP Pavilion running Windows 7 Home Premium. When I was running XP I was able to listen to FM radio direct (not over the internet) using a built-in FM tuner. I don't have that now. Was advised to 'set up' an analog tuner function. How do I do this? OldEd On 3/11/2010 4:30 PM, OldManEd wrote: > I have an HP Pavilion running Windows 7 Home Premium. When I was running > XP I was able to listen to FM radio direct (not over the internet) using > a built-in FM tuner. I don't have that now. Was advised to 'set up' an > analog tuner functio...

Is it a bug in mciSendCommand function?
When I query the length of a large .wav file( larger than 2G,about 46 hours), mciSendCommand return the wrong value. My code is as below: MCI_SET_PARMS mciSetParms; mciSetParms.dwTimeFormat = MCI_FORMAT_SAMPLES; if(m_ErrorCode = mciSendCommand(m_wDeviceID,MCI_SET,MCI_WAIT| MCI_SET_TIME_FORMAT, (DWORD)(LPVOID) &mciSetParms)) { return false; } MCI_STATUS_PARMS mciStatusParms; mciStatusParms.dwItem = MCI_STATUS_LENGTH; if(m_ErrorCode = mciSendCommand(m_wDeviceID, MCI_STATUS,MCI_STATUS_ITEM, (DWORD)(LPVOID) &mciStat...

Sort-function of AutoFilter doesn't work, when sheet is protected
Hi there, I have a sheet with some columns of locked cells and an AutoFilter in the header-line of the sheet. I have to protect the worksheet to protect the formulas in some cells. When protecting, I choose to allow all users to use AutoFilter and Sort function. However, when I open the sheet in protected mode, I can use the AutoFilter-function to filter the data, but then cannot sort the data. A warning appears, that I have to unprotect the sheet in order to sort. Has anyone got an idea how to solve that? I'm using Excel 2003 SP2. Lucas. Make sure that all the cells in the range ...

Importing a DLL: calling function error.
I'm importing a DLL and when I call its function "vDecode" I get an error message (see below). I think that the reason is that the function prototype I have is wrong (the DLL documentation -below- could be wrong, old, obsolete). BUT maybe I'm not importing the DLL right (I have not much experience importing DLLs) I reproduce the code below (simplified). Am I forgetting to do something to make this function work? Thanks a lot! Ricardo. ---------------------------------------------------------------- THE ERROR ========= Debug Error! Program: ... PROYECTOS\_TESTS\Coder\Debu...

Automatic updating
I am familiar with how to do basic linking between worksheets/workbooks. I have multiple worksheets (some on Sharepoint, some on local drive) with different headers that I would like to link/feed automatically into one master worksheet (in a different workbook) without having to manually link each line separately. The information is updated daily in the multiple worksheets by various people. There are also reports generated from an online service that we convert and drop into Excel. The reports are all basically timelines of customer questions, date recv'd, our respons...

Jet SQL functions
Hi I have Microsoft Access 2000 on this computer but I dont find that the help describes Jet SQL functions. Some searching on the Internet reveals Jet SQL functions but these are the usual Group Aggregate functions : AVG, MAX, MIN, SUM, COUNT etc. What I am interested in SQL Server equivalent functions to FLOOR, CEILING, ROUND, CAST, CONVERT Yet when I look in "Microsoft Access Help", there is nothing. It is excpetionally poor at describing Jet SQL, practically zero. Does anyone have a URL on Jet Maths functions? And why is Microsoft Access so badly documented? Thanks Step...

Conditional Formating & Rand() function
Hi there, I have an Excel 97 (I know, not my fault - blame work!) workbook wit the following column headings: ID, NAME, ADDRESS ID is numbered with integers from 1-9 and the others populated a appropriate. I have created a random number in a cell away from this data (A13, a it happens), using =RAND()*(9-1)+1 As you all no doubt know, this creates a random number between 1 & 9 The number it produces is not an integer, and is, I have little doubt the root of my problem. What I wanted to do was apply conditional formatting such that if th number produced by the random function = th...