【发布时间】:2011-08-18 18:41:19
【问题描述】:
您如何在 C++ 中编写此代码?
public bool returnboolean(bool x)
{ return x; }
public double sum(double one, double two)
{ return one+two; }
public string yourname(string name)
{ return "hello "+yourname; }
我去哪里写代码?在 *.h?还是在 *.cpp 中?
这两个班级的目标是什么?因为后来我添加了一个类,它们创建了 2 个类。
如何创建实例?
例如在c#中:
person p1 = new person();
c++ 中 this 的等价物是什么??
【问题讨论】:
-
这里仍然很难说清楚要问什么。
-
天哪 @angel - 你真的需要先阅读 C++ 的基本入门书,并就你不理解的内容提出问题,而不是期望这里的人为你写一个基本的入门书。
-
当你说“那两个类”时,你指的是什么? .h 和 .cpp?它们是文件,而不是类。
-
我不觉得这个网站应该是你的“教程”。如果您有非常具体的编程问题,请提出。问“请帮我转换下面的代码,因为我不懂C++”有点过分了。
标签: c# c++ c visual-c++