The following code doesn't compile.
I have a requirement in my project to declare one template as a friend
function to another..
Can anyone suggest a way????
#include <iostream.h>
template <class B,class Cclass A; //forward declaration
template <class DBT_>
class D{
public:
friend class A<B,C>; //Error as B and C are not known as template
parameters
private :
DBT_ f;
};
template <class B,class C>
class A{
private:
typedef D<BmyClass;
myClass E;
int j;
};
int main()
{
A<int,inta;
return 0;
} 7 1605
Nike wrote:
The following code doesn't compile.
I have a requirement in my project to declare one template as a friend
function to another..
Can anyone suggest a way????
#include <iostream.h>
template <class B,class Cclass A; //forward declaration
template <class DBT_>
class D{
public:
friend class A<B,C>;
You have to be explicit here, B and C are unknown types.
--
Ian Collins.
* Nike:
The following code doesn't compile.
I have a requirement in my project to declare one template as a friend
function to another..
Can anyone suggest a way????
#include <iostream.h>
This is not a standard C++ header. Use <iostreamif you must. But you
don't need it for this code.
template <class B,class Cclass A; //forward declaration
template <class DBT_>
Reserve all uppercase names (except sometimes single letter names like
T, which have established convention) for macros. See this group's FAQ
as well as Bjarne Stroustrup's FAQ.
class D{
public:
friend class A<B,C>; //Error as B and C are not known
template< class B, class C friend class A;
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Thankx for ur suggestions Alf..
I just changed the name of the class what I have in my project to this
format..
As far as this question goes, the question I have is ,
"Is it not @ all possible to have kind of declarations as I have
suggested in the code????
This works with MS VS 2003 --->
class B;
class C;
template <class B, class Cclass A; //forward declaration
template <class DBT_>
class D {
public:
friend class A<B,C>; //Error as B and C are not known as
template parameters
private :
DBT_ f;
};
template <typename b,typename c>
class A{
private:
typedef D<typename bmyClass;
myClass E;
int j;
};
int func()
{
A<int,inta;
return 0;
}
Thanks,
Neel.
* Nike:
Thankx for ur suggestions Alf..
I just changed the name of the class what I have in my project to this
format..
I think you mean you used the syntax I exemplified.
As far as this question goes, the question I have is ,
"Is it not @ all possible to have kind of declarations as I have
suggested in the code????
That depends on what you're trying to achieve. You can use that syntax
for declaring a concrete instantiation of the A template as friend. To
declare the template itself as friend, use the syntax I exemplified.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
* ne*******@redif fmail.com:
This works with MS VS 2003 --->
class B;
class C;
template <class B, class Cclass A; //forward declaration
template <class DBT_>
class D {
public:
friend class A<B,C>; //Error as B and C are not known as
template parameters
private :
DBT_ f;
};
This doesn't make the template a friend, it makes the concrete class
A<B,Ca friend. In particular, A<int,int>, the only instantiation used
in the program, is not a friend of D.
>
template <typename b,typename c>
class A{
private:
typedef D<typename bmyClass;
This is invalid syntax. Use just "b", not "typename b". Even though
MSVC may allow it, "typename" is not a kind spice that you can sprinkle
liberally everywhere in the hope of satisfying the compiler.
Use "typename" to inform the compiler that a dependent name denotes a type.
A dependent name is a name which definition depends on a template
parameter, e.g. Foo<b>::Type.
myClass E;
int j;
};
int func()
{
A<int,inta;
return 0;
}
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On May 22, 11:49 am, "Alf P. Steinbach" <a...@start.now rote:
* neelsm...@redif fmail.com:
This works with MS VS 2003 --->
class B;
class C;
template <class B, class Cclass A; //forward declaration
template <class DBT_>
class D {
public:
friend class A<B,C>; //Error as B and C are not known as
template parameters
private :
DBT_ f;
};
This doesn't make the template a friend, it makes the concrete class
A<B,Ca friend. In particular, A<int,int>, the only instantiation used
in the program, is not a friend of D.
template <typename b,typename c>
class A{
private:
typedef D<typename bmyClass;
This is invalid syntax. Use just "b", not "typename b". Even though
MSVC may allow it, "typename" is not a kind spice that you can sprinkle
liberally everywhere in the hope of satisfying the compiler.
Use "typename" to inform the compiler that a dependent name denotes a type.
A dependent name is a name which definition depends on a template
parameter, e.g. Foo<b>::Type.
myClass E;
int j;
};
int func()
{
A<int,inta;
return 0;
}
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?- Hide quoted text -
- Show quoted text -
Thanks Alf, should have paid more attention !
Thanks,
Neel. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Franks |
last post by:
When I compile my application if there are any .net coding errors they show
up fine in the error list in VS.NET 2005 following my attempt to compile.
However there are also a ton of other errors about the html not being
transitional. I'm not worried about those right now. Is there a way to
suppress those so I only get "real" asp.net errors and not html markup
errors?
Thanks,
Steve
|
by: guy |
last post by:
another intermittent problem...
after a while when doing a build the error list 'Error' and 'Warning' icons
disappear from the error lines but are still visible in the heading (between
Error List and Description)
the column they should appear in is blank.
once gone they stay gone untill VS is reloaded
any ideas?
|
by: crystalattice |
last post by:
I've finally figured out the basics of OOP; I've created a basic character
creation class for my game and it works reasonably well. Now that I'm
trying to build a subclass that has methods to determine the rank of a
character but I keep getting errors.
I want to "redefine" some attributes from the base class so I can use them
to help determine the rank. However, I get the error that my base class
doesn't have the dictionary that...
|
by: Greg |
last post by:
Visual Studio - Line numbers missing from error list
I'm writing an app in ASP.NET using VS 2005. There are no line numbers
with the build errors reported. Any suggestions? I can't find any
reports of anyone else having the same problem. Is there a setting I
may have missed?
Greg.
|
by: Joseph Turian |
last post by:
I have a class Feature defined, which is a kind of Vocab:
template <class T, unsigned I>
class Vocab : boost::totally_ordered<Vocab<T,I {
public:
Vocab();
Vocab(const T& t);
template<typename VVocab(V v, bool dummy);
....
};
| |
by: kimiraikkonen |
last post by:
Hello,
I'm very new to C# and just installed VC# 2005 express edition and i
have VB 2005 express installed previously. But i saw a thing which may
be called as a "Visual C# 2005 express" bug?
For example, in VB 2005 express while i was coding, if there's a
coding error, errors are displayed in error list below the screen
immediately during coding and before starting debugging.
But in VC# 2005 express, if there's a coding error,...
|
by: Peri |
last post by:
Dear All,
Is there a dockable control in VB.NET similar to the Error List Window,
Output Window, Soluition Explorer, Tool Box. I would like to have a control
that has Pin functionality (Auto Hide) and dockable at any place in the Menu
MDI window.
Your help in this is greatly appreciated.
Thanks and Regards,
|
by: Myxamatosis |
last post by:
Upon compiling my code for a fraction class, the error that i get is a good 50 or so repetitions of
error: Class "Fraction" has no member named "Numer"
and
error: Class "Fraction" has no member names "Denom"
I'm guessing it has something to do with the declaration of these private objects in the .h file, and it's use in the source code
here's a snippet of one of the functions
|
by: phpbilder |
last post by:
dear friends,
i am using visual studio php from jcx software (version 5.2.5) and apache from apache friends.com (version 1.6.6a),
now i am trying to transform a xml document to a xsl file, i create a xsltporcessor class for processing, and when i try to run, i will get a fatal error
"Fatal error: Class 'XSLTProcessor' not found", i also checked my phpinfo(), xsl is enabled on,
XSL --------- enabled
libxslt Version...
|
by: mbmccormick |
last post by:
In Visual Studio when developing on VB.NET, we would get an instant error list- before compiling or building the solution. Why doesn't C# have this same functionality? Whenever I want to see my errors, I have to compile first...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |