Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to make a template class a friend?

Posted on 2006-07-10
1
272 Views
Last Modified: 2013-11-17
template<class T> struct plotvalue : public std::unary_function<T, void>
{
  plotvalue(//GraphHandler& g) : gh(g) {}
  void operator() (T x) {
        if(x.Param_code == 0x00000002) {
                double time = (x.Time - gh.start_time)/60;
                gh.series.AddXY(time, x.Measure_Value);
         }
  }
  GraphHandler& gh;
};
//---------------------------------------------------------------------------
class GraphHandler {
        friend template<class T> struct plotvalue : public std::unary_function<T, void>
        public:
                GraphHandler(TCustomSeries& s, TChart& c, TChartEditor& ce);
                void plot(MessageHandler& mh, TCustomSeries* series);
        private:
                bool first_time;
                TCustomSeries& series;
                TChart& chart;
                TChartEditor& chartEditor;
                unsigned __int32 start_time;
};

because this dose't work? Or is it even possible?
0
Comment
Question by:mikrodidakt
1 Comment
 
LVL 30

Accepted Solution

by:
Axter earned 125 total points
ID: 17071129
Hi mikrodidakt,
You can not.
It's not allowed by the C++ standards.

Cheers!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question