DEV Community

Jeff Qi
Jeff Qi

Posted on

Beginning Visual C++ Chapter 1

Projects and solutions
Projects: An container to hold every necessary component of a certain program. All files are stored in the relative project folder, including auxiliary data files, source file.
Solutions: An container to hold multiple of projects. An mechanism to integrate 1 or more programs and other resources together. Solution will store many project-related folders. Adding more projects in 1 Solution is possible but in most cases we add project which only has relationships with other projects in Solution.
Console application

  1. Precompile head file. Application wizard will generate head file 'stdafx.h' including precompile declarations(#include ...)

  2. Program using Unicode, add

    define _UNICODE

    define UNICODE

    in stdafx.h
    instead of main(), using wmain() if you about to use _UNICODE

type of variable: auto
'auto' is a kind of type that can be deduced from the initial value that has been assigned to the variable. Obviously a initial value is necessary if you about to use 'auto'.
auto shall not use with initialization list in the same time:

auto n{16};
which is wrong.

the real type of n in the statement is std::initializer_list

auto n(16);
is of no problem

define type: typeid
get the type of a certain expression. typeid(expression).name()

how to get global variables in a code block?
作用域解析运算符
::global variable name

Top comments (0)