You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
1k, if initialization takes time and I still want it, is tehre anyhow to make my pointers come null without setting it manually? see, not because I don't want to right it, because I seem that I will never ever use unitiliazed pointers with trash on their addressJonathan– Jonathan2009-12-15 22:24:30 +00:00Commented Dec 15, 2009 at 22:24
-
1You initialise class members in the class's constructor - that's how C++ works.anon– anon2009-12-15 22:27:51 +00:00Commented Dec 15, 2009 at 22:27
-
3@Jonathan: but null is trash too. You can't do anything useful with a null pointer. Dereferencing one is just as much an error. Create pointers with proper values, not nulls.DrPizza– DrPizza2009-12-15 22:29:18 +00:00Commented Dec 15, 2009 at 22:29
-
2Initialising apointer to Nnull can be a sensible thing to do.And there are several operations you can perform on null pointers - you can test them and you can call delete on them.anon– anon2009-12-15 22:31:29 +00:00Commented Dec 15, 2009 at 22:31
-
4If you're never going to use a pointer without explicitly initializing it, it doesn't matter what it contained before you gave it a value, and under the C and C++ principle of paying for only what you use, it isn't done automatically. If there is an acceptable default value (usually the null pointer), you should initialize it. You can initialize it or leave it uninitialized, your choice.David Thornley– David Thornley2009-12-15 22:33:33 +00:00Commented Dec 15, 2009 at 22:33
|
Show 11 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-cpp