Bjarne Stroustrup's "The C++ Language Programming" says at P330:
"Within the scope of String<C>, qualification with <C> is redundant for
the name of the template itself, so String<C>::Stri ng is the name for
the constructor. If you prefer, you can be explicit:
template<class T> String<C>: String<C> () { /*...*/ }"
But in fact, I find I cannot use this 'explicit' form for any member
function of a template class with g++ or Comeau.
Is it the problem of the compilers or the book? 4 1524
an0 wrote: Bjarne Stroustrup's "The C++ Language Programming" says at P330: "Within the scope of String<C>, qualification with <C> is redundant for the name of the template itself, so String<C>::Stri ng is the name for the constructor. If you prefer, you can be explicit: template<class T> String<C>: String<C> () { /*...*/ }"
I suspect you mean:
template<class C> String<C>::Stri ng<C> () { /*...*/ } But in fact, I find I cannot use this 'explicit' form for any member function of a template class with g++ or Comeau.
That appears to be the case. Is it the problem of the compilers or the book?
I don't know.
an0 wrote: Bjarne Stroustrup's "The C++ Language Programming" says at P330: "Within the scope of String<C>, qualification with <C> is redundant for the name of the template itself, so String<C>::Stri ng is the name for the constructor. If you prefer, you can be explicit: template<class T> String<C>: String<C> () { /*...*/ }"
But in fact, I find I cannot use this 'explicit' form for any member function of a template class with g++ or Comeau.
Is it the problem of the compilers or the book?
you should get yourself a copy of the c++03 standard, as this is the
definitive instance for questions like this. otherwise have a look at
stroustrup's homepage, it features an errata for tc++pl, maybe your
revision is outdated or stands corrected.
i don't think that this is mentioned anywhere in the standard (surely
not 14.5.1 class templates)... so while not sure i suspect the book is
at fault...
-- peter
I am sorry I have one typo in my first post.
Thank you.
peter steiner wrote: an0 wrote: Bjarne Stroustrup's "The C++ Language Programming" says at P330: "Within the scope of String<C>, qualification with <C> is redundant for the name of the template itself, so String<C>::Stri ng is the name for the constructor. If you prefer, you can be explicit: template<class T> String<C>: String<C> () { /*...*/ }"
But in fact, I find I cannot use this 'explicit' form for any member function of a template class with g++ or Comeau.
Is it the problem of the compilers or the book?
you should get yourself a copy of the c++03 standard, as this is the definitive instance for questions like this. otherwise have a look at stroustrup's homepage, it features an errata for tc++pl, maybe your revision is outdated or stands corrected.
i don't think that this is mentioned anywhere in the standard (surely not 14.5.1 class templates)... so while not sure i suspect the book is at fault...
-- peter
I suspect not.
template<class T> String<C>: String<C> () { /*...*/ }" is valid
according to http://www.open-std.org/JTC1/SC22/WG...fects.html#147
There is a PR against GCC for bugs in not correctly handling the
injected-name rules. I believe it is still not fixed.
-- Bjarne Stroustrup; http://www.research.att.com/~bs This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eshrath |
last post by:
Hi,
What I am trying to do:
=======================
I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are writing one object in C# which will take the entire table tag
contents and renders. Ie., we need to pass "<table>…………
<thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
|
by: BCC |
last post by:
In looking through some code I have inherited, I notice a lot of places
where the programmer used operator() as a function call:
void operator() (int x, int y);
Rather than an explicit function name:
void MyFunction(int x, int y);
Then when he instantiates a class he calls it:
MyClass myclass;
myclass (x, y);
|
by: Steven T. Hatton |
last post by:
I believe the answer is that the language doesn't support the ability to
retain a reference to a std::indirect_array<>, and would be illadvised to
try, but I figure I'll ask just to be sure. What I mean by retaining a
handle is that I would like to have a class that has a member field
functioning as a reference into a valarray initialized by an
indirect_array.
template<typename T>
class IA{
indirect_array<T>& ia_;
|
by: SoilMan |
last post by:
Consider the following:
class xyz
{
public:
template <typename T>
void foo(T x)
{
cout << "foo<T> " << x << endl;
}
|
by: stain |
last post by:
hi,
the following code produces an "illegal explicit template
specialization" warning. I have been fiddling around a while to find a
solution to specialize a template method of a specialized template
class. Here is what I would like to be able to call:
ChannelIndexTraits<RGB>::index<RED>() == 0
ChannelIndexTraits<RGB>::index<GREEN>() == 1
ChannelIndexTraits<RGB>::index<ALPHA>() == -1
| |
by: ajay2552 |
last post by:
Hi,
I have a query.
All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it?
One method is to use <, > ,<Company> to display '<', '>' and '<Company>' respectively.
But is there any freeware code available which could implement the above functionality without having to use >,< and such stuff???
|
by: -Karl |
last post by:
Couls someone please advise me on this error. What I am trying to do
is be able to convert an XML document into arrays. I read that the
subs & functions have to be in <scripttags.
Thanks!
Error:
BC30456: 'Read_DOM' is not a member of
|
by: Protoman |
last post by:
Is this an efficient way to integrate an explicit function of x from a
to b:
#include <iostream>
using namespace std;
class Integrate
{
public:
Integrate(long double (*f)(long double& x)):fn(f){}
|
by: Barry |
last post by:
As boost::pool_alloc use singleton holder for pool allocator, client
programmers have to reclaim the memory by hand through calling
singleton_pool<alloc_tag, elem_size>::purge_memory() or something to
release the memory, so the program should have knowledge of the
elem_size, sometime, it's impossible or at least hard to know the size
of the element allocated by the allocator.
for example:
struct my_tag
list<int, boost::pool_allocator<int...
|
by: jason.cipriani |
last post by:
Is there any difference between declaring a template parameter as a
"typename" or a "class"? E.g.
template <class TT f() { }
template <typename TT g() { }
Thanks,
Jason
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |