Friend operator override for c++ class templates

Entire test program.  When I change the operator from either + or - to *, I get compile errors.  Any ideas?
#include "stdafx.h"
#include <iostream>
using namespace std;
template <typename T>
class mjt {
public:
 mjt();
 friend mjt<T> operator + <>(const mjt<T>& ls, const mjt<T>& rs);
 friend mjt<T> operator - <>(const mjt<T>& ls, const mjt<T>& rs);
template <typename T>
mjt<T>::mjt() { }
template <typename T>
mjt<T> operator +(const mjt<T>& ls, const mjt<T>& rs) {
 mjt<T> result = ls;
 // Magic happens here
 return result;
template <typename T>
mjt<T> operator -(const mjt<T>& ls, const mjt<T>& rs) {
 mjt<T> result = ls;
 return result;
int _tmain(int argc, _TCHAR* argv[]) {
 mjt<int> set1, set2, set3;
 set3 = set1 + set2;
 set3 = set1 - set2;
 char ans;
 cin >> ans;
 return 0;

I think that the most acceptable answers can be found in Standards.
Intuitively,
    friend mjt<T> operator * < > ( const mjt<T> & ls, const mjt<T> & rs );
and
    friend mjt<T> operator * <T> ( const mjt<T> & ls, const mjt<T> & rs );
are similar. They stipulates that only the template implementation of
operator *, such as
    template <typename T>
    mjt<T> operator * ( const mjt<T> & ls, const mjt<T> & rs )
will be the friend of mjt, but only if the types
T of the mjt class and operator * are the same. Therefore the operator made for
<int> type will be friend for mjt<int>, but not for
mjt<float>.
Additionally, the non-template operators, if any, such as the explicitly written
    mjt<int> operator * (const mjt<int>& ls, const mjt<int>& rs)
will not be friends.
In the other variant where the friend declaration includes the
‘template’ keyword:
    template< typename T >
    friend mjt<T> operator * <T> ( const mjt<T>& ls, const mjt<T>& rs );
the T type denotes any type, which can be different from the homonymous type
T that appeared before in class declaration (template< typename T > class mjt …). To avoid confusion, you can write with the same effect:
template< typename T >
class mjt
    template< typename T2 >
    friend mjt<T2> operator * ( const mjt<T2> & ls, const mjt<T2> & rs );
This declares that the operator * of some type, such as
<int>, will be friend for mjt class of any type, not only
mjt<int>, but also for mjt<float>, mjt<int*>, mjt<string>, etc.
I hope that the Standards stipulate the same things.

Similar Messages

  • Operational override for write-delay (system-property)

    Hi all,
    I'm failing to get this xml element to validate within a cache config.
    I'm using Coherence 3.7.1
    <write-delay system-property="myproperty.override.write-delay" >10s</write-delay>.
    the idea is to get the write-delay value atruntime through a system-property (-Dmyproperty.override.write-delay=5s for ex.)
    I'm getting the following failure
    Description
    Location
    Type
    cvc-type.3.1.1: Element 'write-delay' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to 'http://www.w3.org/2001/XMLSchema-instance' and whose [local name] is one of 'type', 'nil', 'schemaLocation' or 'noNamespaceSchemaLocation'. However, the attribute, 'system-property' was found.
    line 41
    XML Problem
    Do you know if the override is valid at that location? The documentation says YES.
    What am I doing wrongly?
    Thanks,
    Harry

    Hello Leo_TA,
    thanks for the answer.
    Actually I need a default value which can be overriden at runtime as described in the documentation
    http://docs.oracle.com/cd/E18686_01/coh.37/e18677/appendix_cacheconfig.htm#BHCECGCF
    This is very handy to move conifguration items outside the cache-config.
    Do you know why the xml woul dnot validate when system-property is used in the write-delay?
    <?xml version="1.0" encoding="UTF-8"?>
    <cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
                  xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
    </cache-config>
    Coherence accepts it (when we force no xml validation (removing the xmlns)).
    But I would like to use the xml validation to avoid miss-configurations.
    Regards
    Harry

  • HT202879 I would like to have a spreadsheet editing software for my new Template Numbers Pro but my operating system is 10.7.  Are there other editing software programs (less the 10.9) that can work with this app?

    Hi,
    I am looking for some editing software for my new Template Numbers Pro.  Numbers is 10.9, my computer is only 10.7.  What do you suggest?
    Thanks,
    Billieoh

    Billieoh wrote:
    That is good to know.  Frankly I don't know what kind of machine I have.  I have a Mac OSX Lion 10.7.3 early 2008.
    If it's the "Templates for Numbers Pro" on the Mac App Store then you need OSX 10.7 or later.  You'll need iWork '09 or later.
    It looks as if you want to use the iOS version of the same templates then you will need the latest Numbers there.  And if you use the latest Numbers there and want to sync to the Mac, you'll need to have Mavericks and Numbers 3.
    SG

  • Classpath for java class for Business Operation

    I am running wls 7.0 with wli on Solaris.
    I am running studio on my developemt w2k pc and connectioning to my unix wls.
    I want to define a business operation using my FCV.class. Where should I put the
    class (pc or server) and where do I need to append my classpath information ?

    Business operations can only access classes from the application and extension
    classpath. This is a WLI limitation.
    Giora
    "Davidson Hutton" <[email protected]> wrote:
    >
    I am running wls 7.0 with wli on Solaris.
    I am running studio on my developemt w2k pc and connectioning to my unix
    wls.
    I want to define a business operation using my FCV.class. Where should
    I put the
    class (pc or server) and where do I need to append my classpath information

  • Class template in uml

    Has anyone used the class template in uml diagrams? I am trying to use a class template for writing and reading data. I am having trouble using the template parameters as an input type or return type for operations within the template class.

    I have a class template DataReaderListener. The template parameter is ElementType. One of its operations is take() and should return data of type ElementType. I want to show that the class RawPulseListener is derived from DataReaderListener with RawPulse substituted for ElementType. So in my uml diagram I am using the derivation classifier to show RawPulseListener. Then I use the derivation edge to show the relationship between the template class DataReaderListener and the derived class RawPulseListener. Is this correct?

  • How to assign approvaal policy for a request template in OIM 11g

    When I request for resource in OIM 11g, It's always going for Default approval of xelsysadm.
    I want this Request level approval must go to "Beneficiary Manager approval". While requesting I am selecting request template (which I created) for Provision resource as Request type.I have already set "Beneficiary Manager approval" as request level approval for this request template.
    I have created one approval policy, How can I assign this approval Policy to request template so that When i submit this request , it should go to my Manager approval.
    Regards,
    J

    Hi Rajiv,
    I do not need approval of Operational level. I want to stop the approval process after request level approval.
    Here you are saying to create a new approval policy and set as AUTO Approval as true. There are some default approval policies which comes with OIM 11g and one of the approval policy is trigeering the Operaional level approval. So I think I do not need to create new approval policy and I can use exsting approval policy and modify as you suggested selecting AUTO APPROVAL and create approval rule as request template=="XYZ".
    I am not sure which default approval policy trigeering the Operational approval now. Can you pls tell me that?
    Can you pls confirm that, there is only way to restrict Opertional Approval by selecting "AUTO APPROVAL" true and put the approval rule as request template=="XYZ"
    Thanks Rajiv for your help all the time.

  • Not able to created Number Ranges for Asset Classes in AS08

    Dear Friends,
    I am not able create Number Ranges for Asset Classes in AS08.
    It is giving me an error message as company code does not exist.
    When I Check Consistency under path SPRO -> Financial Accounting -> Asset Accounting -> Preparing for Production Startup -> Check Consistency -> Overview Report: Company Codes. I am getting the following
    RSOL  Reliance Sealink One PLtd                                            
    CoCode no. alloc.    NKTR                                                
    Fiscal Year Variant  V3   Apr.- March, 4 special periods                 
    Start 2nd half month 00                                                  
    Transfer date        31.03.2006                                          
    Chart of dep.        TOLL Chart of Depreciation - For Highway Projects   
    Net worth tax        01   Book depreciation as per Compinies Act 1956    
    Enter net book value                                                     
    Status company code  2                                                   
    Current fiscal year  2007                                                
    Doc. type dep. pstng AF   Dep. postings                                  
    > Number range &1 in co.code &2 for doc.type &3 must be defined as internal
    Calc.insur.value                                                         
    Input tax exempt         
    If you see the above first two line you will find the difference is that Company code RSOL in the first line and NKTR company code in the second line.
    Actually CoCode no. alloc. has been wrongly copied as NKTR while copying CoCode it should be RSOL and not NKTR.
    I think because of this wrong allocation it is giving me an error in AS08. Also it is not showing me CoCode in drop down list in AS08.
    Please help me to resolve the problem.
    Thanks
    Rahul Jain

    Look in TC OAOB if the company code is assigned to a chart of depreciation

  • For all classes used in the alv reports.

    we need the list of required classes used in alv reports this urgent .
    please help me.

    Hi Navid,
    Check <b>SLIS Package/Dev.Class for node Classes</b>,
    here u will find all required <b>classes for ALV including ALV Hierarchical,AVL Tree, ALV HTML.</b>
    Classes.
    CL_ALVHT_HTMLINPUT-> ALV: HTML Input (Control Proxy)
    CL_ALVHT_HTML_PAGE-> ALV HTML Page
    CL_ALVHT_HTML_TEMPLATE-> ALV: HTML Templates
    CL_ALVHT_TAGSTREAM-> ALV
    CL_ALVHT_UI_ELEMENT-> ALV: HTML User Input Element
    CL_ALV_BDS-> BDS Access and Data Retention
    CL_ALV_CHANGED_DATA_PROTOCOL-> Message Log for Data Entry
    CL_ALV_DD_DOUBLE_LISTBOX-> Management Class for two D&D List Boxes
    CL_ALV_DD_LISTBOX-> D&D List Box
    CL_ALV_EVENT_DATA-> Changing Data Container for Events
    CL_ALV_EVENT_TOOLBAR_SET-> ALV Context Menu
    CL_ALV_GRAPHICS-> ALV Graphic (Integration with GFW)
    CL_ALV_GRAPHICS_CU-> Customizing of ALV Graphics
    CL_ALV_LISTBOX_DRAGOBJ->
    CL_ALV_OI BDS-> Access and Data Retention
    CL_ALV_TABLE_CREATE-> Dynamic Creation of ALV Data Table
    CL_ALV_TREE_BASE-> Basis Class ALV Tree Control
    CL_ALV_VARIANT-> ALV Variant Management
    CL_GUI_ALV_GRID-> ALV List Viewer
    CL_GUI_ALV_GRID_BASE-> Basis Class for ALV Grid
    CL_GUI_ALV_TREE-> ALV Tree Control
    Regards,
    Raghav
    Message was edited by:
            Raghavendra  L

  • TestStand create different object for singleton class

    Hi all,
    we have a singleton class which has some functions used to do testing a harware.
    Our main Exe will create an object for that singleton class(which opens Com1 port and communicate with hardware). so the Exe will do basic communication test with hardware it is working well. We are using Teststand operator interface to do various testing by using sequence files. Main exe will use teststand usercontrols to execute tests when the user clicks Testbutton. after that, teststand try to create an object for that singleton but it returns new object not the existing one which is created by EXE. So it throwing me exeception "Com1 port access denied." (since we created object for signleton class @ very first in EXE)
    My question is Since that teststand runs in a separate Appdoamin will the singltonclass create separate object for different appdomain? if so is there any solution to reslove this?
    Hope i clearly explained my probs.
    Thanks in advance
    Srini 

    Hi Srini,
    How are you calling the executable?  From a Call Executable step?  Or are you using another means of calling it?   Also, why is TestStand trying to recreate the object?  As long as you have the correct handle to the object I don't think it matters what app domain you are in.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • MO: Operating Unit Non Usable Operating Unit for Multi-Org Conversion

    Hello Hussein
    I enabled multi org in 11i and mo Operating unit values set as Non Usable Operating Unit for Multi-Org Conversion, is ok to set is value or will that cause any responsibility.
    In R12.1.3 I am getting an error like this
    APP-FND-02902: Multi-Org profile option is required. Please set either MO: Security Profile or MO: Operating Unit profile option.
    Please advice
    Thanks
    Prince

    user12094010 wrote:
    Hello Hussein
    I enabled multi org in 11i and mo Operating unit values set as Non Usable Operating Unit for Multi-Org Conversion, is ok to set is value or will that cause any responsibility.This might cause issues.
    ORA-20001: APP-FND-2902: Multi-Org Profile Option is Required [ID 399910.1]
    How To Prevent the Profile Option MO: Operating Unit being set to NULL at Site Level? [ID 393560.1]
    In R12.1.3 I am getting an error like this
    APP-FND-02902: Multi-Org profile option is required. Please set either MO: Security Profile or MO: Operating Unit profile option.
    Please adviceR12 - Error ORA-20001, APP-FND-02902 Accessing Profile Classes Form With Multi-Org Access Control (MOAC) Enabled [ID 602141.1]
    Unable To Open Customer Account Details, Error :ORA-20001: APP-FND-02902: Multi-Org profile option is required [ID 987165.1]
    Entering to Profile Classes Gets Ora-20001, App-Fnd-02902. Multi Org Profile Option Is Required [ID 465132.1]
    Error 'ORA-20001: APP-FND-02902: Multi-Org Profile Option Is Required' When Open Account Details [ID 1406860.1]
    Some Web Pages Fail To Load After Patch Application [ID 1281328.1]
    You may also search MOS website for APP-FND-02902 and go through the docs.
    Thanks,
    Hussein

  • Does Less Than ( ) operator works in the data template SQL within CDATA ??

    All,
    I am trying to use <= operator (<= sysdate) in the data template sql query and it's throwing Java exceptions.
    I have CDATA around my sql and XML parser should ignore '<' symbol. Query works fine if I use 'ampersandlt;=' operator. Here is my query
    <sqlStatement name="Q_1" dataSourceRef="">
    <![CDATA[select * from table where date_column <= sysdate]]>
    </sqlStatement>
    Just want to know if this is a bug.
    Thanks
    Problem was solved. Use 'ampersandlt;' where ampersand is '&' for less than

    Try this..
    select * from table where date_column <= sysdate

  • How to update Appraisal Override flag in the templates found in PHAP_ADMIN

    Whenever a customized transaction is used for approving a Batch, the change should get reflected in the two templates found in standard transaction PHAP_ADMIN.
    However, on changing the value of Appraisal override flag of the batch, the change is not reflected in the templates found in PHAP_ADMIN.
    Is there any ABAP code available for updating Appraisal Override flag in PHAP_ADMIN templates?

    Hi Siva,
    I think there is no utility to create appraisals and update details from offline data for PMP.
    Regards,
    Vinayaka
    Edited by: Vinayaka Prabhu on May 9, 2012 4:04 PM

  • Overiding Mandatory Fields for master Agreement Template

    Hello,
    In the standard creation of the master agreement template the CONTACT field is mandatory. To me, this does not make sense because a template would need to be created for every contact/supplier.  We want to make the CONTACT field optional for master agreement templates.  I am trying to create a page customization with the following properties to accomplish this:
    UI ID:contracts.contract.ui.buyside.default
    Name:Master AgreementParent
    Class: Master Agreement
    Field ID: Contact
    Property: required
    Value: no
    Dimension on parent set
    Dimension Field :  IS_TEMPLATE
    Dimension Field Type: Boolean
    Dimension Value: yes
    I can not seem to make it work.  Any suggestions?  Is this even possible?
    Thanks in advance,
    Kyle

    Thanks for the quick reply.  I was hoping to avoid a dummy vendor.  This is sure a strange piece of software.
    Kyle

  • An error on a site deleted a photobucket folder full of pictures for a class and I'm trying to see if since I last veiwed them with firefox theres a way to recover them-With the cache or something?

    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    An error on a site deleted a photobucket folder full of pictures for a class and I'm trying to see if since I last veiwed them with firefox there is a way to recover them-With the cache or something?
    == This happened
    ==
    Just once or twice
    == I was on photobucket around 6pm on Mon July 19th
    ==
    == Firefox version
    ==
    3.5.9
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9
    == Plugins installed
    ==
    *-The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
    *Shockwave Flash 10.0 r42
    *My Web Search Plugin Stub for 32-bit Windows
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape
    *DivX Web Player version 1.4.3.4
    *npdnu
    *Office Plugin for Netscape Navigator
    *iTunes Detector Plug-in
    *GEPlugin
    *4.0.50524.0
    *MSN® Toolbar
    *Google Updater pluginhttp://pack.google.com/
    *RealJukebox Netscape Plugin
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *6.0.12.69
    *Google Update
    *Java Plug-in 1.4.2_03 for Netscape Navigator (DLL Helper)

    Hi- I'm Sarie and no this didn't help. I actually tried to log in to respond and it said I wasn't registered. Not really all that cool.

  • Maximum no'of Objects for one class

    Hello friends
    Please, tell me....Maximum no'of Obects for One Java class.
    Thanks & Regards
    S.Rajakrishna

    Is there any limit of creating the objects for One class?Instantiated objects go into the heap. There is only one heap for the whole JVM. There is no correlation between objects in the heap and the individual class files.
    100,000 objects may or may not fit into the heap. In general they probably will. If you don't, then yes, you'll get an Out Of Memory exception.
    Regardless there is no excuse for loading 100,000 objects just to render a JSP! You don't imagine your user is going read all of them do you? Restrict them to the number of objects that the user is actually going to be able to handle at any given time.
    You can do this by putting WHERE clauses on the hibernate query, and/or by setting limits (setFirstResult and setMaxResult) on the Query object before listing it.

Maybe you are looking for