C ++/CLI is. the C ++ language on the NET platform, of course, the syntax of iso c ++ is retained, and the stack object is one of them, but its semantics has changed, when an object is returned, the memory occupied by the object is automatically released.
Everyone knows. the biggest difference between the NET platform and the win32 platform is the managed memory. Anyone who knows about C # knows that C # contains value type and refrence type ), value Type objects are allocated to the stack, and all referenced objects are allocated to the managed stack.
In other words, the object type determines the allocation location, stack or managed stack. The collection of stack memory is still the same as in the past. It is deterministic. The collection of managed heap memory is the responsibility of the garbage collector. However, in such a memory model, what is the meaning of MyClass myClass; in C ++/CLI?
As we all know, the emergence of advanced languages is mainly attributed to the compiler, And the semantics depends on the Compilation results of the compiler. The following describes some simple code. Pay attention to the comments in the code.
- private:
- class SingleTonTranslator
- {
- public:
- SingleTonTranslator()
- {
- signal(SignalExceptionClass::GetSignalNumber(),
- SignalHandler);
- }
-
- static void SignalHandler(int)
- {
- throw SignalExceptionClass();
- }
- };
-
- public:
- SignalTranslator()
- {
- static SingleTonTranslator s_objTranslator;
- }
- };
-
- // An example for SIGSEGV
- class SegmentationFault : public ExceptionTracer, public
- exception
- {
- public:
- static int GetSignalNumber() {return SIGSEGV;}
- };
-
- SignalTranslator<SegmentationFault>
- g_objSegmentationFaultTranslator;
-
- // An example for SIGFPE
- class FloatingPointException : public ExceptionTracer, public
- exception
- {
- public:
- static int GetSignalNumber() {return SIGFPE;}
- };
I have read countless articles describing the complexity of C ++, and I have discussed the complexity of C ++. I wrote two articles about C ++ ). I have always felt like a blind person. As criticized by a reader of "Why C ++.
In this article, I did not specify what is C ++'s "non-essential complexity ". Of course, I can know it by myself, and even if I have been in contact with C ++ for a while, however, new users or even non-beginners have no specific understanding of what I call "non-essential complexity, this leaves the article "Why C ++" out of its original intent-oriented to all C ++ users and learners.
For the same reason, after writing the article "How should you learn C ++/CLI?", Mr. Meng asked me to write a series of articles for "programmer, let me introduce my attitude and understanding changes in the process of getting in touch with C ++, although I am very happy to agree.
However, until now, three months have passed, and the particles have not been collected. Why? Because I don't think the real nature of the problem is clearly touched; so I haven't done anything until now, so I don't want to talk nonsense, except for being able to read as a novel, it may not be of any practical use to those who really want to learn or even use C ++/CLI.
- Introduction to C ++
- Summary Notes on learning and exploring C ++ library functions
- Basic Conception and method of C ++ Class Library Design
- Does C ++ really have market value?
- Basic Conception and method of C ++ Class Library Design