# How to pass parameters to vtk constructor?

**URL:** https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397
**Category:** Support
**Created:** [December 14, 2021, 5:34am UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397 "2021-12-14T05:34:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [December 14, 2021, 5:34am UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397/1 "2021-12-14T05:34:35Z")

</div>

Generally, we use `vtkSmartPointer` to create a object as:

```auto
vtkSmartPointer<vtkConeSource> cone = vtkSmartPointer<vtkConeSource>::New();

```

After reading the source code of `vtkConeSource`, I find it accept a parameter in the constructor:

```auto
protected:
    vtkConeSource(int res=6);

```

Then, how can I pass the parameter to `vtkConeSource`?

`vtkSmartPointer<vtkConeSource>::New(6)` is wrong.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [December 14, 2021, 10:02am UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397/2 "2021-12-14T10:02:22Z")

</div>

It is protected and is the default resolution. Use `SetResolution()` to change the resolution. There are other parameters of the cone that you can also change, see: [vtkConeSource](https://vtk.org/doc/nightly/html/classvtkConeSource.html). There are also some links to vtk-examples using vtkConeSource.

Regarding protected constructors, this may give you more information: [What are practical uses of a protected constructor?](https://stackoverflow.com/questions/1057221/what-are-practical-uses-of-a-protected-constructor/1057245).

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [December 14, 2021, 10:34am UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397/3 "2021-12-14T10:34:34Z")

</div>

Btw, this contstructor parameter is very old code and should be deprecated to avoid these kind of misunderstanding.

git tells me it was commited in 1995 by @ken-martin 🙂

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [December 14, 2021, 1:28pm UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397/4 "2021-12-14T13:28:59Z")

</div>

Yes 100%

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [December 14, 2021, 1:45pm UTC](https://discourse.vtk.org/t/how-to-pass-parameters-to-vtk-constructor/7397/5 "2021-12-14T13:45:00Z")

</div>

Note that there are also bits of documentation, usually in the .cxx file but I think even occasionally in the .h file, which refers to these construction parameters… lots of clean up to do
