473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VC++ 7.1 friend template problem

Consider the following code:

template<class T>
struct Singleton
{
static T& Instance()
{
static T instance;
return instance;

}
};

template<class T>
struct A : public Singleton<A<T> >
{
// causes error C2245
friend A& Singleton<A<T> >::Instance();
};

A<int>& i = A<int>::Instance();

Comeau online is OK with it, VC++ is not.
It is a bug or am I missing something?

Cheers,
Jarda
Nov 16 '05 #1
1 1009
Jaroslav Gresula wrote:
Consider the following code:

template<class T>
struct Singleton
{
static T& Instance()
{
static T instance;
return instance;

}
};

template<class T>
struct A : public Singleton<A<T> >
{
// causes error C2245
friend A& Singleton<A<T> >::Instance();
};

A<int>& i = A<int>::Instance();

Comeau online is OK with it, VC++ is not.
It is a bug or am I missing something?


Looks like a bug to me.

-cd
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christophe Barbe | last post by:
I posted a few days ago about the same problem but was not very clear. So here is my second take at it. Basically with GCC 3.3.2, I can't compile the example from the C++ FAQ Lite available...
0
by: Oliver Kowalke | last post by:
Hi, following code will not compile with MS VC 7.1: struct null_type; template< bool B, typename T, typename E > struct if_then_else; template< typename T, typename E >
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
4
by: Justin Miller | last post by:
Ok, I tried to make that subject as descriptive as possible. What I'm trying to do: I'm attempting to use policies to create a generic memento (design pattern) template. My Memento template so...
5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
2
by: Emil Dotchevski | last post by:
This code causes the compiler to allocade a *lot* of memory *very* fast, and even when I hit ctrl+break it still takes about a minute for my system to recover and start responding to user input...
0
by: Dilip | last post by:
Vaclav I have taken the liberty to cross-post this microsoft.public.dotnet.languages.vc which has more visibility from MSFT VC++ team. thanks --Dilip Actual post by Vaclav Haisman...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
7
by: Amu | last post by:
Hi i am stuck up in a part of project where i have to inherit the VC++ template classes into C#.net. Please provide me the solution for this .
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.