2017/10/14

How to get the DJANGO version


  1. To type python bring you to the python environment. Before doing that, make sure if you already set up a virtual python environment, if yes, activate it. 
>> python 

      2. Type these commands:
>> import django
>> django.VERSION
The key word version is capital

2013/10/16

[Track] Helpful python blog.

http://stackoverflow.com/questions/152480/python-blogs-that-you-regularly-follow

It also mentions that someone has asked that the C++ blog which people regular follows.

2013/04/18


No, please reference to this critical issue

https://groups.google.com/forum/?fromgroups=#!topic/phonegap/k_gnyxYGS-M

PhoneGap make a big mistake, its audio's extension is mp3, but in reality it's encoded in 3gp.

The audio format which are supported by Android system are listed here:
https://developer.android.com/guide/appendix/media-formats.html

Although it mentions about the mp3 file, Phonegap doesn't really do that.





2013/04/13

Stackoverflow history: 弄清楚 new/delete 是dynamic 在run time 且是heap, local 則是在stack



2
From: 
http://stackoverflow.com/questions/6337294/creating-an-object-with-or-without-new
This is probably a basic question, and might have already been asked (say, here); yet I still don't understand it. So, let me ask it.
Consider the following C++ class:
class Obj{
    char* str;
public:
    Obj(char* s){
        str = s;
        cout << str;
    }
    ~Obj(){
        cout << "Done!\n";
        delete str;
    }
};
what's the difference between the following code snippets:
Obj o1 ("Hi\n");
and
Obj* o2 = new Obj("Hi\n");
Why the former calls the destructor, but the latter doesn't (without explicit call todestroy)?
Which one is preferred?
share|edit|flag
4
Which C++ text book are you using? And have you looked at the "related" questions over there =======>>>>>> – nbt Jun 13 '11 at 22:48
1
Both are borken as they try and delete a pointer they do not own. You can not delete a pointe that was retrieved from "Hi there" – Loki Astari Jun 13 '11 at 22:53
1
Even if they owned the pointers, the class itself would still be broken due to deleting the pointer in the destructor, but having compiler generated copy constructor and assignment operator (violation of the rule of the three). So any copy of the class would mean two objects trying to delete the same pointer – Grizzly Jun 13 '11 at 23:09
I hope you mean delete instead of destroy (which doesn't exist). – Christian RauJun 13 '11 at 23:19
Along with the suggestions from others, you should be treating char* as array. So, use delete[] instead of delete. – Jagannath Jun 13 '11 at 23:36
add comment

marked as duplicate by TheVillageIdiotcobbalSteve FentonMehrdad AfshariIn silico Jun 14 '11 at 7:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers


up vote13down voteaccepted
Both do different things.
The first creates an object with automatic storage duration. It is created, used, and then goes out of scope when the current block ({ ... }) ends. It's the simplest way to create an object, and is just the same as when you write int x = 0;
The second creates an object with dynamic storage duration and allows two things:
  • Fine control over the lifetime of the object, since it does not go out of scope automatically; you must destroy it explicitly using the keyword delete;
  • Creating arrays with a size known only at runtime, since the object creation occurs at runtime. (I won't go into the specifics of allocating dynamic arrays here.)
Neither is preferred; it depends on what you're doing as to which is most appropriate.
Use the former unless you need to use the latter.
Your C++ book should cover this pretty well. If you don't have one, go no further until you have bought and read, several times, one of these.
Good luck.

Your original code is broken, as it deletes a char array that it did not new. In fact,nothing newd the C-style string; it came from a string literal. deleteing that is an error (albeit one that will not generate a compilation error, but instead unpredictable behaviour at runtime).
Usually an object should not have the responsibility of deleteing anything that it didn't itself new. This behaviour should be well-documented. In this case, the rule is being completely broken.
share|edit|flag
1
"Automatic storage duration" is colloquially known as "on the stack", (since this storage is usually part of the thread's function call stack, and is discarded when the function exits) and "dynamic storage duration" is colloquially known as "on the heap".– Mike DeSimone Jun 13 '11 at 23:00
1
@Mike: Yes, and I despise those terms with an astronomical passion. It's quite deliberate that I did not employ them; I'm the last person that you'll ever see propagating those inaccurate phrases. – Lightness Races in Orbit Jun 13 '11 at 23:01
@Mike: (Still, I understand that it may be useful for the OP to be aware of the connection; so, thanks for that.) – Lightness Races in Orbit Jun 13 '11 at 23:02
I posted them because they're in the vernacular and Sadeq's going to see them. That's all. I don't care for them either, but I use both since I usually have to document embedded systems, where you really do need to know if something is on the stack or not. – Mike DeSimone Jun 13 '11 at 23:05
upvote
flag
Powered By Blogger

追蹤者