-
August 23rd, 2010, 03:06 AM
#1
Is a default constructor with default values is parametric or nonparametric ?
class A defines default constructor with default values.
I) Is it default or parameterised constructor?
My opinion is that it is parametric when it is called with values like A a1(x1,y1) and it is default when it is called like A a2()? Pl suggest.
Code:
class A
{
int a;
int b;
public:
A(int x=10,int y=20)
{
}
};
Last edited by forumuser11@gmail.com; August 23rd, 2010 at 04:55 AM.
-
August 23rd, 2010, 03:57 AM
#2
Re: Is a default constructor with default values is parametric or nonparametric ?
Originally Posted by forumuser11@gmail.com
class A defines default constructor with default values.
I) Is it parametric or non-parametric?
I have never heard of these terms used before in the context of your question. Parametric? non-Parametric? What is that supposed to mean? A default constructor can have arguments if all the arguments are defaulted. Basically, a default constructor is a constructor that is able to construct an object with no arguments given. Any other explanation further than that is fluff.
My opinion is that it is parametric when it is called with values like A a1(x1,y1)
You called it with parameters. Whatever "parametric" is supposed to mean, I don't know.
and it is non-parametric when it is called like A a2()?
First of all, this:
does not construct an object. What it does is declare a function called a2() that takes no arguments, and returns an A object.
What you mean is this:
As far as non-Parametric, you constructed an A with no parameters, therefore you called the default constructor.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; August 23rd, 2010 at 04:09 AM.
-
August 23rd, 2010, 04:01 AM
#3
Re: Is a default constructor with default values is parametric or nonparametric ?
The only use of the word parametric I have ever seen is combined with polymorphism: "parametric polymorphism", which is basically a very strange (and confusing in a C++ context) way to say "template".
You'd better ask your teacher to be more clear about his question, or review your class material. Or change class.
Last edited by monarch_dodra; August 23rd, 2010 at 04:03 AM.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
August 23rd, 2010, 08:26 AM
#4
Re: Is a default constructor with default values is parametric or nonparametric ?
"parametric" is a mathematical term, I've never heard it in computer science outside of that context. In math, a parametric equation is an equation that shows a relationship between two variables.
-
August 23rd, 2010, 08:33 AM
#5
Re: Is a default constructor with default values is parametric or nonparametric ?
Maybe "Default optionally-parameterised constructor" will be OK for your teacher...
-
August 23rd, 2010, 12:28 PM
#6
Re: Is a default constructor with default values is parametric or nonparametric ?
Parametric polymorphism is the counterpart to ad hoc polymorphism. The former describes generic behavior independent of the type of the object or objects, the latter the distinct behavior dependent of different type of the object or objects. "template" is just a C++ term for compile time polymorphism, usually which is parametric but not necessarily (specializations are ad hoc) as well as parametric classes and their counterpart(ad hoc classes?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|