我正在尝试在 MacOS 上使用 VS 代码调试以下 try C++ 程序。它需要用户的输入。它只是将两个数字作为输入并返回一个数字列表作为输出的东西。这是我的launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/hello",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我按 F5 时,确实启动了一个外部终端窗口,但它不执行输出文件“hello”,它只是在我的主文件夹中显示常规提示〜。如果我只是正常运行文件,一切都会正常运行。我将发布我正在尝试调试的确切代码作为示例,因为它足够简单。
#include <iostream>
using namespace std;
class Calculator
{
private:
/* data */
public:
Calculator(/* args */) {} …Run Code Online (Sandbox Code Playgroud) 我试图填写一张地图,上面有文字及其出现次数.我正在尝试写一个lambda来做它,就像这样:
Consumer<String> wordCount = word -> map.computeIfAbsent(word, (w) -> (new Integer(1) + 1).intValue());
Run Code Online (Sandbox Code Playgroud)
map是Map<String, Integer>.如果它不存在,它应该只是将地图中的单词作为键插入,如果它存在则应该将其整数值增加1.这个语法不正确.