Class Parameters in C++
Class Parameters in C++
Dear All,
Please anybody give some good definition, syntax and example for "Class paramters" in C++
Please anybody give some good definition, syntax and example for "Class paramters" in C++
Re: Class Parameters in C++
Context?
"C++ class parameters" could be anything, from an awkward wording for a template class' parameters to something completely different.
"C++ class parameters" could be anything, from an awkward wording for a template class' parameters to something completely different.
Every good solution is obvious once you've found it.
Re: Class Parameters in C++
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...
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...
Every good solution is obvious once you've found it.
Re: Class Parameters in C++
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++
Dear Solar, Berkus,
I am not able to understand your quotes. Actually when I study about "Class Template Specialization", I read the below code
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.
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 ;
}
From the above code I understood the concept "Class Template Specialization" but the lineOutput:
stream<typename T1, typename T2>::f()
stream<typename T1, int>::f()
Code: Select all
class stream<T1, int>
And I dont know, how to use these two types "<T1, int>" inside the class definition.
Re: Class Parameters in C++
Sorry, that example is actually "Class Template Partial Specialization".berkus wrote:Awesome! Can you briefly explain it in your own words?osdevkid wrote:From the above code I understood the concept "Class Template 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++
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.
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.
Every good solution is obvious once you've found it.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Class Parameters in C++
You're hereby convicted of fraud. Your answer shows up 1:1 in google, which means they can never be your own words.if the template arguments of the partial specialization can be deduced from the actual template argument list.
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++
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.
Code: Select all
stream<double, int> sc;
Actually my doubt is in the line (second template definition)
Code: Select all
class stream<T1, int>
Code: Select all
template <typename T1, int>
Actually I have confused lot, because of the below additional C++ syntax rules added for Template partial specialization.
Code: Select all
class stream<T1, int>
Code: Select all
template <typename T1, int>
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Class Parameters in C++
Solar wrote:For learning a programming language, this is the wrong board.
I'm going to ask for a thread lock now.berkus wrote:Heh, I was right about the "can't read" part.
Re: Class Parameters in C++
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.
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++
Dear Berkus,
I am in right forum.
I am in right forum.
General Programming
Programming, for all ages and all languages.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Class Parameters in C++
The point of rules is that you have to follow all of them, not just one of your choice.forum rules wrote:3: Please try to meet the intellectual requirements
Re: Class Parameters in C++
When you try being a nitpick, expect to be nitpicked.
At the very top of the page it reads:
At the very top of the page it reads:
In the Forum Rules it reads:OSDev.org
The Place to Start for Operating System Developers
The linked Wiki article "Getting Started - Required Knowledge" 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.
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.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.
Every good solution is obvious once you've found it.