小编Ste*_*cob的帖子

反编译C#与C++

我已经阅读了许多关于反编译的帖子(虽然没有经验),但不明白为什么所有人都普遍提到反编译C#比C++可执行文件更容易.谁有人解释这个区别?

c# c++ decompiling

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

c ++ filt不会解码typeid名称

我在GCC C++编译器上运行代码,输出type_info :: name:

#include <iostream>
#include <typeinfo>

using namespace std;

class shape {
   protected:
   int color;
   public:
   virtual void draw() = 0;
   };


class Circle: public shape {
   protected:
   int color;
   public:
   Circle(int a = 0): color(a) {};
   void draw();
   };

   void Circle::draw() {
   cout<<"color: "<<color<<'\n';
   }

class triangle: public shape {
   protected:
   int color;
   public:
   triangle(int a = 0): color(a) {};
   void draw();
   };

   void triangle::draw() {
   cout<<"color: "<<color<<'\n';
   }

int main() {
   Circle* a;
   triangle* b; …
Run Code Online (Sandbox Code Playgroud)

c++ typeid typeinfo c++filt demangler

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

fstream没有创建新文件

我正在尝试学习动态文件访问.我的代码如下:

int main()
{
    dtbrec xrec; // class object
    fstream flh;

    // Doesn't create a new file unless ios::trunc is also given.
    flh.open("database.txt", ios::in | ios::out | ios::binary);

    flh.seekp(0,ios::end);
    xrec.getdata();
    flh.write((char*)&xrec, sizeof(dtbrec));

    flh.close();
}
Run Code Online (Sandbox Code Playgroud)

我认为fstream默认情况下会创建一个新文件'database.txt'(如果它不存在).关于什么可能是错的任何想法?

c++ file-io fstream

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

虚拟析构函数:不工作?

我正在使用GNU编译器.B类中的虚拟析构函数不会调用析构函数~D().谁能告诉我为什么?

#include<iostream>
using namespace std;

class B {
  double* pd;
  public:
  B() {
  pd=new double [20];
  cout<< "20 doubles allocated\n";
  }

  virtual ~B() {   //the virtual destructor is not calling ~D()
  delete[] pd;
  cout<<"20 doubles deleted\n";
  }

  };

class D: public B {
  int* pi;
  public:
  D():B() {
  pi= new int [1000];
  cout<< "1000 ints allocated\n";
  }
  ~D() {
  delete[] pi;
  cout< "1000 ints deleted\n";
  }
  };

int main() {
  B* p= new D; //new constructs a D object
Run Code Online (Sandbox Code Playgroud)

删除应该在类B中调用虚拟析构函数,但它不会. …

c++ virtual-destructor

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

如何在不打开文件的情况下在 vi 中应用正则表达式命令

我有一组需要相同编辑集的多个文件,我正在尝试创建一个 bash 脚本以在 vi 中编辑它们,但是我不知道如何在脚本中使用 vi 进行编辑?任何的意见都将会有帮助。

vi vim bash editor

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

是否将指针设置为空分配的内存?

我正在阅读一个将指针初始化为空的代码,最初我认为该代码没有将新内存分配给用于存储二维值数组的指针(它确实如此),这让我想知道,是一个初始化为空指针的指针分配的内存?

class Int8_tSet : public GridSet
{
public:
  int8_t** set;
//
//
  Int8_tSet():set(0) {}
  Int8_tSet( const Int8_tSet& x ):set(0) {copy(x);}
  virtual ~Int8_tSet() { Free2DArray(set);}
//
// --- opeartor
  int8_t  operator() ( IntVector2D x ) const {return set[x.i][x.j];}
  int8_t& operator() ( IntVector2D x ) {return set[x.i][x.j];}
// --- function
  void Set();
  void Set(int8_t val);
  void Set( IntVector2D x ){ NS_GRIDDATA::Set(x,*this,(int8_t)-1); }
  void Set( IntVector2D x,int8_t val){ NS_GRIDDATA::Set(x,*this,val); }
  void Switch();
// --- output & input
  void Output(std::ostream& out ) const;
  void …
Run Code Online (Sandbox Code Playgroud)

c++ memory null pointers allocation

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