Foo*␣name, foo␣*name, foo␣*␣name, or for*name are all exactly the same.
If you create a handle to a class object, you are responsible for their deletion. Use them only if you have no other choice.
So it doesn't matter where the * symbol placed? As long as the class is there, and the pointer is there, it will work?
Correct it comes down to personal style.
Correct it comes down to personal style.
Thank you for the answer.
Now, why we used declaration of an object as pointer, and what is it's purpose compared to the syntax below :
Foo *foo2=new Foo("foo2");
Why not just simple declaration like :
What's the difference between both?Foo foo2("foo2");
Thank you for the answer.
Now, why we used declaration of an object as pointer, and what is it's purpose compared to the syntax
below :
Foo *foo2=new Foo("foo2");
Why not just simple declaration like :
What's the difference between both?Foo foo2("foo2");
- 2010.09.09
- manzy704manzy704 1,02122 gold badges88 silver badges33 bronze badges
- stackoverflow.com
Thank you nicholi shen.
The latter, you are responsible for their deletion.
The latter, you are responsible for their deletion.
By the latter, do you mean this ?
Foo *foo2=new Foo("foo2");
By the latter, do you mean this ?
Foo *foo2=new Foo("foo2");
He does.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello developer, I'm new here. I read code base and not found answer to my question.
What is the difference with
Foo *foo2=new Foo("foo2");
and
Foo* foo2=new Foo("foo2");
And when are they used?
Regards
Simon Anderson