小编Ang*_*gry的帖子

为什么复制ctor在此代码中使用?

class A
{
 public:
  A(const int n_);
  A(const A& that_);
  A& operator=(const A& that_);
};

A::A(const int n_)
{ cout << "A::A(int), n_=" << n_ << endl; }

A::A(const A& that_)    // This is line 21
{ cout << "A::A(const A&)" << endl; }

A& A::operator=(const A& that_)
{ cout << "A::operator=(const A&)" << endl; }

int foo(const A& a_)
{ return 20; }

int main()
{
  A a(foo(A(10)));    // This is line 38
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

执行此代码给出了o/p:

A :: …

c++ copy-constructor

10
推荐指数
2
解决办法
686
查看次数

安全ASCII char在存储之前替换空格

我的代码将大量文本数据传递给遗留的lib,后者负责存储它.但是,它往往会删除尾随空格.当我读回数据时,这是一个问题.由于我无法更改遗留代码,因此我考虑用一些不常见的ASCII字符替换所有空格.当我回读文本时,我可以将它们替换回来.

  1. 这是一个坏主意,考虑到我无法触及传统存储代码?
  2. 我可以用哪个角色代替?我正在考虑一些超过180的char.

数据中只有空格 - 没有制表符或换行符.数据是字母数字,带有特殊字符.

whitespace ascii

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

标签 统计

ascii ×1

c++ ×1

copy-constructor ×1

whitespace ×1