- Qzone log
| Back to logs list
818969 2010 年 11 月 29 日 12:04 Reading (loading. ..) Comments (0) Category: Personal Diary
mainly want to learn a bit about C + +, VS 2010 I heard a lot of improvement in this area, install one, test it, indeed, can be made directly to the form as a C #.
C + + mainly in the following two improvements
The first is the improvement of MFC. Visual Studio 2010 support for C + + and expansion has been very large, the introduction of many new classes, and MFC support for Windows 7-style UI, C + + developers there is no reason not to use the Visual Studio 2010.
Second, the new language standardization. In Visual Studio 6.0, because there are too many places the compiler can not subsequently the C + + standard has been criticized match. Cloud Age Visual C + +, in Visual Studio 2010,, Visual C + + compiler will be a very mature and reliable C + + compiler, a. Microsoft's next generation of C + + standard compliant compiler will be combined with powerful Visual Studio.NET development environment enables developers to develop applications more handy.
C # side, not too well
But before I upgrade a project I found that relatively large changes in TreeView with us,
justin bieber shoes, not a little property, and some changed. My problem is on the point of node name, this is not the same. Because do not want to load the previous version of the DLL, so do a bit changed. It took some time. Incidentally, the project several bug fixes in a moment, by the way also the security module to upgrade a bit. Set more respect!
The following new features VS2010
turn planted
VS2010 is considered to be writing a Visual Studio 6 to carry the tripod to make. Not only is the use of the IDE WPF reconstruction, and use the latest NET Framework 4 as a powerful back-up support. Remarkable from top to bottom. Here we look at areas in which dramatic VS2010 -
1) WPF reconstruction of the interface: the VS2010 IDE Full reconstruction using WPF, so tightly integrated with Win7 appearance, but also achieved all previous versions can not be achieved NET features - such as code Promise Zoom (opens a project You should see the bottom left corner of the display ratio, the default 100%; so you do not have to change the font size, you can manually enter a percentage, you can select the drop-down, of course, can shortcut Ctrl + mouse wheel to adjust.)
2) Quick Search:
I) If you want to find a class (methods) where the call directly to select the method (class name),
cheap supra, IDE will automatically open the document in the current purple circle with all of the class (methods ) name.
II) shortcut key
3) Architecture System View:
want to know exactly which files a project, call the relationship between them in VS2010 easy - you have to do is open the structure of the browser (in the View menu,
supra shoes cheap, Architecture Explorer), then you can Click the Solution View or Class View to view the current item (or the whole solution) of the classes, methods, and so on. You can also search through the text input box (click on a funnel icon, and search the same way as the You can also use the Ctrl + A way to select all the classes (methods), click on the
course, you want to know the areas in which a method is called, you can right in the method, select
4) third-party testing program:
you can completely do not know the circumstances of its third-party testing program, this is a major breakthrough. First you create a Test Project, Right to join Coded UI Test file, opens select the operation (be sure to press the lower right corner before the recording action of the button), and then click again until after the completion of the stop recording button, then click the right side of the debugging code.
5) Optional and named parameters if (C #):
If you want to omit some of the earlier argument, you have to override the function defined multiple times in order to obtain different parameters in the form of these functions. Parameter is omitted in the built-in VB.NET functions, but C # programmers can catch up. Now do not it! C # also can do a lot less for you to open the door to an overloaded function. For example: DoTask (string taskName, bool Repeat = false) {... ...}, but may be in the final definition of default parameters,
supra skytop shoes, examples of the Repeat to move taskName is not permitted before, and the default parameters of the assignment must be const type (either written dead, either const variable can not be otherwise).
At the same time, VS2010 also supports out of order to the parameters of the assignment - what does this mean? If a function has multiple parameters, as long as you (the function name: value) This way, you can arbitrarily assign a parameter to any function.
If there is an interface.
6) covariant and contravariant (Co-variant & Crop-variant)
This is a VS2010 add content, for sure at compile time whether to allow different types of generic interface exists between the conversion problem.
order to understand the
Suppose we define an interface and a number of categories:
class Father
{
public virtual void Say ()
{
Console.WriteLine (
}
}
class Son: Father
{
public override void Say ()
{
Console.WriteLine (
}
}
class Son2: Father
{
public override void Say ()
{
Console.WriteLine (
}
}
Interface InAndOut
{
void Input (V value);
T Output ();
}
class Program : InAndOut
{
private object value = default (V);
public T Output ()
{
return (T) value;
}
public void Input (V tv)
{
value = tv;
}
}
and if we have to instantiate an instance of two interfaces:
InAndOut iobj1 = new Program ();
InAndOut iobj2 = new Program ();
now we make: iobj1 = iobj2, feasible?
At first glance, it seems possible - why? Because the right to associate two subclasses implicitly Son will be automatically converted into its parent Father. Is like Father f = new Son () as you can (Note: We handle class is implicitly converted into the parent class as Moreover, according to the interface definition, the input direction is to accept a Son (actually stored in the iobj2, was implicitly converted to Father), the output is stored when the Son is implicitly converted into Father output.
kind of logical thinking is certainly not wrong, but it has a precondition - that the input from the iobj1 direction, must be Son to the Father, then the output must also be a Son to the Father! However, only a generic definition of who can ensure the Father or the Son in the class must be input (or output) parameters? If we change into the following form?
class Program : InAndOut
{
private object value = default (T);
public V Output ()
{
return (V) value;
}
public void Input (T tv)
{
value = tv;
}
}
so that there is a problem - first, iobj1 point iobj2 (to accept the parameters of a Father, at this time if my Father Enter the Son2,
cheap supra shoes, then the actual conversion to the Son, an exception occurs when a; Similarly, the output because it is Son2 not translate into Son, so an exception.)
this is because the direction of input and output caused by uncertainty. If we start to force a given input (output orientation). That V can only be used as input, T can only be output on it.
by extension, assuming the existence of two generic T and V, assuming V: T (V is a subclass of T). Then the generic interface conversion between the general rule is: the output type is the parent class, Generic input and output constraints that rule is: add keywords interface output line out, input plus in. As follows:
Interface InAndOut
{
void Input (V value);
T Output ();
}
you enter the following code,
supra purple shoes, you can output the results:
InAndOut iobj1 = new Program ();
InAndOut iobj2 = new Program ();
this rule is essentially to understand the behavior of the compiler. However, the results are not necessarily correct to study the following examples:
InAndOut iobj1 = new Program ();
InAndOut iobj2 = new Program ();
This piece of code can still compile, but running is still reported exception. Why? Because the must do this:
InAndOut iobj1 = new Program ();
InAndOut iobj2 = new Program ();
inputs accept Son, can turn into a blue implicitly Father, Father blue objects stored in the same sub-class must be converted into Son (that is, a covariant things must be able to support its anti-transformation; the other hand, an anti- change must support its covariant generic generic, which is the famous
prove that: (red Son started): implicit into Father (covariant), and blue Father (which store the Son) to force into the green Son (anti-change).
Similarly, the (Father black start): Black Father returns the contents of the (storage Son) Father can force the content into the blue (anti-change), but can be implicitly converted into green Son (covariant). I think we can use the diagonal rule validation (imagine, for any generic A, B, C, D):
InAndOut
; (B either transferred as D, can also be transformed into C; output A contains the contents of the
; ; can be converted into D, but also can be converted into C)
InAndOut