C ++ Console :: WriteLine() - 类似没有.net框架的方法

时间:2017-05-29 10:03:51

标签: c# c++ .net

是否有可能在没有.net框架的C ++中编写一个Console :: WriteLine()方法? 我想做的是这样的事情:

Console::WriteLine("Hello! " + "This PC is " + Convert::ToString(3) + " years old!");

.net框架版本看起来像msdn.com上的char [] + char []?

编辑:我能告诉海湾合作委员会吗?也许使用字符串类来进行"" -declarations而不是char-arrays?

EDIT2:我正在尝试编写自己的函数。所以不,我不会使用cout

EDIT3:唯一真正的问题是,是否可以"Hello! " + "This PC is " + string("3")。我知道string("3") + " hello " + "PC!"有效,因为字符串类的+ Operator会将string("3")添加到" hello "并将其转换为string,然后添加{{1}转到string("3 hello ")并将其转换为"PC!"

1 个答案:

答案 0 :(得分:0)

是的,使用来自iostream标题的cout流对象:

std::cout << "Hello! " << "This PC is " << getPcAge() << " years old!"<< std::endl;