hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2class B : public A{}
template <class X3class C: public B<Xreal1, Xreal2>;
Now is it necessary to put the following statement before the line
above like the following
template <Xreal1, Xreal2class B;
Anyway, the line "template <class X3class C: public B<Xreal1,
Xreal2>;" is already showing the path to this hierarhcy,
And also, why do that have to instantiate the class B when you are
talking about the class C.
Since I am getting g++ compilation errors due to it.
I am not able to give the code out as it is too sphegtti type and get
some people confused ( like I did )
The pseudo code should help I guess 4 1478
On 2007-11-16 18:05:49 -0500, "pa********@hotmail.com"
<pa********@hotmail.comsaid:
hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2class B : public A{}
template <class X3class C: public B<Xreal1, Xreal2>;
Now is it necessary to put the following statement before the line
above like the following
template <Xreal1, Xreal2class B;
Anyway, the line "template <class X3class C: public B<Xreal1,
Xreal2>;" is already showing the path to this hierarhcy,
And also, why do that have to instantiate the class B when you are
talking about the class C.
Since I am getting g++ compilation errors due to it.
I am not able to give the code out as it is too sphegtti type and get
some people confused ( like I did )
The pseudo code should help I guess
No, it doesn't help, because it's not at all clear what's real and
what's pseudo, nor did you mention what the error you got was. The
obvious problems are: Xreal1 and Xreal2 are neither declared nor
defined, so you can't use those names to instantiate B. And since A is
declared but not defined, you can't use it as the name of a base class.
As ever, write a small example that produces the problem that you're
running into.
--
Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
( www.petebecker.com/tr1book)
On 17 Nov., 00:05, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2class B : public A{}
template <class X3class C: public B<Xreal1, Xreal2>;
The syntax of what you attempt above is
template <class X3,class Xreal1,class Xreal2class C: public
B<Xreal1, Xreal2>;
>
Now is it necessary to put the following statement before the line
above like the following
template <Xreal1, Xreal2class B;
Yes it is - you have to declare B before you can use it!
Anyway, the line "template <class X3class C: public B<Xreal1,
Xreal2>;" is already showing the path to this hierarhcy,
And also, why do that have to instantiate the class B when you are
talking about the class C.
Surely any instantation of class C must instantiate class B? If you
dont believe so, your expectations are wrong. You could declare the
class without instantiating it, of course:
template <Xreal1, Xreal2class B;
template <class X3,class Xreal1,class Xreal2class C: public
B<Xreal1, Xreal2>;
>
Since I am getting g++ compilation errors due to it.
I am not able to give the code out as it is too sphegtti type and get
some people confused ( like I did )
If you are confused already know, you should take it as a hint that
the code needs a rewrite. Just imagine how confused you will be if you
look at the code again in six months (not to mention if it becomes the
job of a collegue of yours).
/Peter
On 2007-11-16 19:31:17 -0500, peter koch <pe***************@gmail.comsaid:
On 17 Nov., 00:05, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
>hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2class B : public A{}
template <class X3class C: public B<Xreal1, Xreal2>;
The syntax of what you attempt above is
template <class X3,class Xreal1,class Xreal2class C: public
B<Xreal1, Xreal2>;
Maybe. But if Xreal1 and Xreal2 are the names of types, then B<Xreal1,
Xreal2is fine as originally written. Which is why this "pseudo-code"
is pointless.
>
>> Now is it necessary to put the following statement before the line above like the following
template <Xreal1, Xreal2class B;
Yes it is - you have to declare B before you can use it!
No, the template B has already been defined. Aside from the fact that
its definition isn't valid, because it says that A is a base class, but
A hasn't been defined.
And, of course, the message header says something about contructors,
although the "pseudo-code" doesn't show any constructors.
It's rarely worthwhile trying to figure out what sketches like this are
supposed to show. Which is why the FAQ says to post complete, minimal
examples. That way, people can compile the code for themselves and see
what's really going on.
--
Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
( www.petebecker.com/tr1book)
On Nov 16, 4:45 pm, Pete Becker <p...@versatilecoding.comwrote:
On 2007-11-16 19:31:17 -0500, peter koch <peter.koch.lar...@gmail.comsaid:
On 17 Nov., 00:05, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2class B : public A{}
template <class X3class C: public B<Xreal1, Xreal2>;
The syntax of what you attempt above is
template <class X3,class Xreal1,class Xreal2class C: public
B<Xreal1, Xreal2>;
Maybe. But if Xreal1 and Xreal2 are the names of types, then B<Xreal1,
Xreal2is fine as originally written. Which is why this "pseudo-code"
is pointless.
Now is it necessary to put the following statement before the line
above like the following
template <Xreal1, Xreal2class B;
Yes it is - you have to declare B before you can use it!
No, the template B has already been defined. Aside from the fact that
its definition isn't valid, because it says that A is a base class, but
A hasn't been defined.
And, of course, the message header says something about contructors,
although the "pseudo-code" doesn't show any constructors.
It's rarely worthwhile trying to figure out what sketches like this are
supposed to show. Which is why the FAQ says to post complete, minimal
examples. That way, people can compile the code for themselves and see
what's really going on.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
Sorry Pete
Here A has already defined. I am sorry I did not put that, but my
intentions were somewhere else.
Lets forget the tree from A and above
By the way, I got the purpose of declaring the line above.
Thanks to all. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gert Van den Eynde |
last post by:
Hi all,
A beginners question....
I've got a template class
template <class T> classA {...}
In an other class, I want to pass a pointer to an instance of classA as a
function argument....
|
by: Gomaw Beoyr |
last post by:
Two question about the "partial classes" (in the next wersion of
..NET).
Question 1
==========
Will partial classes (in the next version of C#) have to be
declared "partial" in ALL places.
...
|
by: Hasani \(remove nospam from address\) |
last post by:
I was reading a ppt ( http://www.gotdotnet.com/team/pdc/4064/tls310.ppt )
and came aross this statement.
"Users can leverage a destructor. The C++ compiler generates all the Dispose
code...
|
by: norton |
last post by:
Hi,
I am learning Regular Expression and currently i am trying to capture
information from web page.
I wrote the following code to capture the ID as well as the Title
Dim regex = New Regex( _...
|
by: herpers |
last post by:
Hello,
I probably don't see the obvious, but maybe you can help me out of this
mess.
The following is my problem:
I created two classes NormDistribution and DiscDistribution. Both
classes...
|
by: sharpblade |
last post by:
The title of these Item is "Make header files self-sufficient"
There're two examples in this Item:
Example 1: Dependent names. Templates are compiled at the point where
they are defined, except...
|
by: Steven T. Hatton |
last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash,
Mathematica, SML, or LISP. A college teacher recently posted to this
newsgroup regarding her observation that there has...
|
by: JohnQ |
last post by:
Is that I can approximate using my ideal of a language in it. On the flip
side, what I dislike most about it is all the
flak/protecting-the-golden-calf one gets when using it that way.
I think a...
|
by: kevin |
last post by:
Hello!
So I was reading O'Reilly's C++ in a Nutshell when I came accross
something interesting:
The class definition for basic_ostream contains numerous overloaded
operator<< functions:
...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |