Declare class variable to call advanced constructor

Oct 3, 2012 at 9:55pm
Is is possible to declare variable to be able call constructor (e.g. with parameter), of course parameter somehow should be pointed out within declaration.
Oct 3, 2012 at 10:02pm
Yes, every variable made, automatically calls a constructor for that particular class, and maybe that for base classes too.
Oct 3, 2012 at 10:12pm
Base- no, only within inheritance. Maybe you understand my question wrong. I need to declare variable not in heap (via new operator) but do it statically
e.g.
static TVectorNeighbs<27> vnb;

The problem is TVectorNeighbs constructor has parameter i should point out in within declaration.
Oct 3, 2012 at 10:50pm
icegood wrote:
Base- no, only within inheritance

Yeah forgot to add that but that's what I meant. How can a class be called "base" when nothing inherits from it??
Oct 3, 2012 at 10:53pm
I think maybe you're looking for this?

1
2
3
4
5
// maybe what you're looking for?
SomeClass object(15);  // <- calling a constructor that takes a param

// similar call with new:
SomeClass* object = new SomeClass(15);
Oct 4, 2012 at 11:59am
Thanks, Dish. That what i exactly want.
Topic archived. No new replies allowed.