且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在指针上使用重载运算符

更新时间:2023-11-10 10:33:10

需要先解引用指针.

A *ptr = new A();
(*ptr) << "Something";

唯一的另一种方式是你上面描述的方式

The only other way is the way you described above

下面安德烈的解决方案也是可行的,但正如他所说,这可能不是一个好主意.

Andre's solution below is workable as well, but like he said it may not be a good idea.