This commit is contained in:
Bob Brown 2019-03-25 21:10:52 -07:00
Родитель 0f8e7b2d7b
Коммит 7e5f22f862
7 изменённых файлов: 38 добавлений и 39 удалений

6
.gitignore поставляемый
Просмотреть файл

@ -1,3 +1,7 @@
# ignore cache files for sample projects
.vscode/ipch
browse*.db*
browse*.db*
*.obj
*.pdb
*.exe
*.ilk

Просмотреть файл

@ -2,19 +2,18 @@
#define BOX_H
/**
* Box object
* Defines Box and its properties
* Definition of a box object with three dimensions.
*/
struct Box {
public:
int length;
int width;
int height;
int volume(int length, int width, int height){
struct box
{
int length;
int width;
int height;
int volume()
{
return length * width * height;
}
}
};
#endif

Просмотреть файл

@ -1,20 +1,24 @@
# Box Sample
This sample is a simple C++ program that takes console input (box dimensions) and computes their sum (box volume).
This sample is a simple C++ program that computes and outputs the volume of a box.
We use this example in our blog posts to illustrate new extension features.
## Build and Debug Active File
Available as of March 2019, "Build and Debug Active File" automatically configures the build tasks and kicks off a build and debug session.
Available as of March 2019, "Build and Debug Active File" automatically configures the build tasks and kicks off a build and debug session. There are
three ways to get started with this feature.
### Command
While editing a file in your workspace folder, you can open the command palette and select the `C/C++: Build and Debug Active File` command.
This option will generate a tasks.json file for you, build your active source file, and then launch the debugger.
![Open command palette and select Build and Debug Active File](build_debug_command.png)
### Context Menu
While editing a file in a workspace folder, you can right click in the editor field and select the "Build and Debug Active File" context menu option.
This option will generate a tasks.json file for you, build your active source file, and then launch the debugger.
![right click and select Build and Debug Active File](./Code Samples\BoxConsoleSample\build_debug_active_file.png)
Your tasks.json and launch.json files will be created and the project will build and launch the debugger mode.
### Command
Another way to begin building and debugging your active file is to execute the command by pressing "F5".
Just like with the context menu, your tasks.json and launch.json files will be created and the project will build and launch the debugger mode.
![Right click and select Build and Debug Active File](build_debug_context_menu.png)
### F5
Another way to begin building and debugging your active file is to execute the command by pressing <kbd>F5</kbd>. This method will configure
both a tasks.json and launch.json file for you, build your active source file, and then launch the debugger.

Просмотреть файл

@ -1,24 +1,16 @@
#include <iostream>
#include "Objects/box.h"
using namespace std;
/**
* Main takes in Box dimensions
* Calculates and prints Box volume
* Calculate and print the volume of a box.
*/
int main() {
Box package;
package.length = int{};
cout << "Enter package length: \n" << std::flush;
std::cin >> package.length;
package.width = int{};
cout << "Enter package width: \n" << std::flush;
std::cin >> package.width;
package.height = int{};
cout << "Enter package height: \n" << std::flush;
std::cin >> package.height;
cout << "Package volume is: " << package.volume(package.length, package.width, package.height) << endl;
int main()
{
box package{ 10, 10, 10 };
cout << "Package length: " << package.length << endl;
cout << "Package width: " << package.width << endl;
cout << "Package height: " << package.height << endl;
cout << "Package volume: " << package.volume() << endl;
}

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 166 KiB

Двоичные данные
Code Samples/BoxConsoleSample/build_debug_command.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 26 KiB

Двоичные данные
Code Samples/BoxConsoleSample/build_debug_context_menu.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 33 KiB