小编spy*_*ler的帖子

Intellij IDEA正则表达式字符类不能在字符范围内使用

错误形式intellij想法

IDEA不会允许此错误,我无法找到关闭这些错误的选项.有谁知道如何修复错误或关闭警告.javascript工作正常只有IDEA认为这是一个问题

javascript regex intellij-idea

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

在C++中从文件中读取2D char数组

首先,我对c ++的了解是非常有限的,这是我的第一堂课,所以这可能看起来很愚蠢,但请耐心等待,我会请你保持它有点简单或提前解释得非常好.

好的目标是我想用里面的规则创建这个文件,这样我就可以在一个单独的函数中读取它.然而,当我运行这个我没有错误,但它首先出来没有任何空格,我得到一些随机的ascii在最后.

这是运行代码的结果Welcometothetypinggame1.Typetheentiresentenceinoneline2.IstimedandwillaffectthescoreØ-™wîú{Dx&a¼Ë'©ÉaDx&a®pa

#include <cstdlib>
#include <fstream>
#include <iostream>

int main(int argc, char** argv) {
//set the sentences i want the file to print
char o[3][40]={"Welcome to the typing game             ",
            "1. Type the entire sentence in one line",
            "2. Is timed and will affect the score  "};

//creating the file to read in
ofstream out;
out.open("rules.txt");
for(int i=0;i<3;i++){
    for(int x=0; x<39; x++){
        out<<o[i][x];
    }
    out<<"\n";
}
out.close();


//creating a new array to read the data that was stored …
Run Code Online (Sandbox Code Playgroud)

c++ arrays fstream 2d char

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

用于二叉树的c ++析构函数

当我运行析构函数时,我得到一个运行失败,我不知道为什么这是我的树头

class ExpressionTree {
private:
    ExpressionNode* root;
public:
    ExpressionTree() :
    hashmap(100000),
    root(NULL) {
    };
    virtual ~ExpressionTree(){
        helper(root);
    }

    void helper(ExpressionNode *node) {
        if ( !node ) {
            return;
        } else {
            helper( node->getLeft( ) );
            helper( node->getRight( ) );
            delete node;
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

和我的节点标题

class ExpressionNode {
private:
    ExpressionNode* left;
    ExpressionNode* right;
    string data;
public:
    virtual ~ExpressionNode(){
        delete left;
        delete right;
    }
};
Run Code Online (Sandbox Code Playgroud)

现在一切正常,如果在ExpressionTree类中我只会破坏根,但我相信我会以这种方式泄漏内存.这实际上是正确的方式还是我的递归破坏有问题.

c++ binary-tree destructor

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

标签 统计

c++ ×2

2d ×1

arrays ×1

binary-tree ×1

char ×1

destructor ×1

fstream ×1

intellij-idea ×1

javascript ×1

regex ×1