小编Not*_*Pr0的帖子

跨越字符串的初始化并跳转到标签大小写

我正在尝试为我的程序做案例菜单。我总是收到交叉初始化错误,我以前从未见过这个错误。也许有人可以向我解释我的代码出了什么问题。

#include <iostream>
#include <cstdlib>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <fstream>

using namespace std;

#define N_CARS 1

struct car{
    string model;
    int year;
    double price;
    bool available;
}cars [N_CARS];


void menu();
void mainMenu();

void writeToFile(ofstream &outputFile , const car& p)
{
    outputFile << p.model << " "
               << p.year << " "
               << p.price << " "
               << p.available<<"\n";
}

int choice1 = 0;


int main(int argc, char** argv) {

    menu();
    return 0;
}


void menu() {

    do …
Run Code Online (Sandbox Code Playgroud)

c++ menu switch-statement

3
推荐指数
1
解决办法
1万
查看次数

React更新后useReducer钩子需要3个参数

我在更新 React 和 @types/react 版本时遇到问题16.9.0(如果我升级更多,这个问题仍然存在)。它说:Expected 3 arguments, but got 2.

代码:

const [state, dispatch] = React.useReducer<State<D>, Action<D>>(reducer, {
    loading: false,
    data: undefined,
    error: undefined
  });
Run Code Online (Sandbox Code Playgroud)

我试图找到第三个参数是什么,但我发现它只是可选的。也许有人有同样的问题?

typescript reactjs react-hooks

1
推荐指数
1
解决办法
4183
查看次数

标签 统计

c++ ×1

menu ×1

react-hooks ×1

reactjs ×1

switch-statement ×1

typescript ×1