Page 1 of 1
Class Parameters in C++
Posted: Mon May 23, 2011 5:03 am
by osdevkid
Dear All,
Please anybody give some good definition, syntax and example for "Class paramters" in C++
Re: Class Parameters in C++
Posted: Mon May 23, 2011 5:34 am
by Solar
Context?
"C++ class parameters" could be anything, from an awkward wording for a template class' parameters to something completely different.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 5:54 am
by Solar
Ah, come on, berkus.
Cut 'em some slack.
While I understand getting annoyed with "easy" questions like these, venting your anger over them too often drags down the signal / noise ratio just as much as the questions themselves...
Re: Class Parameters in C++
Posted: Mon May 23, 2011 5:58 am
by qw
Especially when the question comes from Osdevkid, who has shown to be an example to all noobs on the forum.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 5:59 am
by osdevkid
Dear Solar, Berkus,
I am not able to understand your quotes. Actually when I study about "
Class Template Specialization", I read the below code
Code: Select all
#include <iostream>
using namespace std;
template <typename T1, typename T2>
class stream
{
public:
void f() { cout << endl << "stream<typename T1, typename T2>::f()"; }
};
template <typename T1>
class stream<T1, int>
{
public:
void f() { cout << endl << "stream<typename T1, int>::f()"; }
};
int main()
{
stream<char, float> si ;
stream<double, int> sc ;
si.f();
sc.f();
cout << endl;
return 0 ;
}
Output:
stream<typename T1, typename T2>::f()
stream<typename T1, int>::f()
From the above code I understood the concept "
Class Template Specialization" but the line
is confusing me, I think "
<T1, int>" is "
Class Parameters" am I right ?
And I dont know, how to use these two types "
<T1, int>" inside the class definition.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 6:09 am
by osdevkid
berkus wrote:osdevkid wrote:From the above code I understood the concept "Class Template Specialization"
Awesome! Can you briefly explain it in your own words?
Sorry, that example is actually "
Class Template Partial Specialization".
And what I understood is, partial specialization match a given actual template argument list, if the template arguments of the partial specialization can be deduced from the actual template argument list.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 6:25 am
by Solar
In explaining, don't use only the difficult words, use examples, they're easier to understand.
In asking, don't use only the difficult words, use examples, as you are not 100% sure on the subject you are asking about, so the difficult words you're using might be wrong. Even if they're correct, the people you are asking might doubt that fact given that you are unsure on the subject.
And, not to forget, for most people on this forum, there are
two language barriers to cross.
That being said, I still don't have a clear picture of what you're unsure about.
And, to reiterate the things that berkus and Hobbes hinted at, in a more friendly manner:
OS development should be done in a language you are intimately familiar with. For learning a programming language, this is the wrong board.
http://www.stackoverflow.com has become the standard target for such generic programming questions.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 6:26 am
by Combuster
if the template arguments of the partial specialization can be deduced from the actual template argument list.
You're hereby convicted of fraud. Your answer shows up 1:1 in google, which means they can never be your own words.
I'm going to side with berkus here: you're a waste of time, please get out. And let's hope that you don't do this at school because it will get you in a lot of trouble if they find out.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 7:21 am
by osdevkid
Yeh, I understood, when we call this line
the second template definition will be called.
Actually my doubt is in the line (second template definition)
is it necessary ? instead we can specify it in the above line like this,
but it gives error, so we have to specify the
Template partial specialization, when we declare the Template Class.
Actually I have confused lot, because of the below additional C++ syntax rules added for
Template partial specialization.
Shall we recommend C++ compiler developers to have it in the Template definition itself like below
I may be wrong, please correct me, why they are following this syntax to accomplish
Template partial specialization.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 7:29 am
by Combuster
Solar wrote:For learning a programming language, this is the wrong board.
berkus wrote:Heh, I was right about the "can't read" part.
I'm going to ask for a thread lock now.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 7:40 am
by osdevkid
Dear Combuster,
Thank you for your words, quotes etc., Defnitely you are a genious, no doubt.
You blame me, shame me, etc,. why don't you try to give more info on my question for my understanding.
More students (like me) are coming to this forum, to learn and clarify their doubts, if they see your answers like above, they will defnitely hesistate to post their basic doubts.
I Hope you understand. Thank you once again.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 8:07 am
by osdevkid
Dear Berkus,
I am in right forum.
General Programming
Programming, for all ages and all languages.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 8:19 am
by Combuster
forum rules wrote:3: Please try to meet the intellectual requirements
The point of rules is that you have to follow all of them, not just one of your choice.
Re: Class Parameters in C++
Posted: Mon May 23, 2011 8:26 am
by Solar
When you try being a nitpick, expect to be nitpicked.
At the very top of the page it reads:
OSDev.org
The Place to Start for Operating System Developers
In the
Forum Rules it reads:
3: Please try to meet the intellectual requirements
We are not here to babysit new programmers. Operating system development requires academic thinking and a large amount of knowledge. If you don't have the
required knowledge then you may learn faster elsewhere.
The linked Wiki article "Getting Started - Required Knowledge" reads:
Programming experience: Learning about programming with an OS project is considered a bad idea. Not only should you know the language in which you will be developing inside out, you should also be familiar with version control, debugging, etc. - in short, you should have written quite a few user-space programs in that language successfully before trying OS development.
Please note that pointing you to
http://www.stackoverflow.com is an attempt to be
helpful. You will meet a much more generous community there, as far as beginner programmer's questions are concerned.