C++ in Visual Studio 2015

Sign in to queue

Description

Developers working on C++ projects know how important the language is to their organization, Microsoft is no different with many of our core tools and services created using C++, with the help of Visual Studio.

Join us for a panel discussion with the C++ product team on how Visual Studio "14" brings many new features and enhancements to help you with improving your productivity, code quality and application performance. We'll dive into what's new in areas such as code editing, debugging and profiling, Build performance and the continued path of further C++ 11/14 language conformance.

Tag:

C++

Day:

2

Code:

029

Embed

Download

The Discussion

  • User profile image
    carlospined​ag

    Is the same semantic of pre-increment and post-increment operators in C++ and C#?

    The following C++ program displays 6, either if you compile including the "/clr" option or without this option:

    #include <stdio.h>
    void main()
    {
      int i = 1;
      printf("%i\n",++i + ++i);
    }

    But the following code in C# displays 5:

    using System;
    class P1
    {
      public static void Main()
      {
        int i = 1;
        Console.WriteLine(++i + ++i);
      }
    }

    Also Java displays 5:

    class P1
    {
      public static void main(String[] args)
      {
        int i = 1;
        System.out.println(++i + ++i);
      }
    }

     

  • User profile image
    chrisaverage

    @carlospinedag Order of modifying the same variable in a single sequence point is not specified in c++ and leads to undefined behavior. It can print 5 with one compiler, 6 with another and format your hard drive with some other.

  • User profile image
    sb216

    If the variable i is declared either as static or volatile the output is 5. Just wished to confirm if C++ has any specifications for modification of static or volatile variables in a single sequence point 

  • User profile image
    carlospined​ag

    @chrisaverage: thanks a lot.

Add Your 2 Cents