⇤ ← 于2007-05-13 23:13:20修订的的版本1
381
备注:
|
675
|
删除的内容标记成这样。 | 加入的内容标记成这样。 |
行号 1: | 行号 1: |
== C++ == {{{#!cplusplus #include <iostream> #include <string> using namespace std; class Message { private: string txt; public: Message(string s){ txt = s;} void Print() const { cout << txt;} }; int main() { Message M("Hello world"); M.Print(); } }}} |
C++
Delphi
program hellopas; {$APPTYPE CONSOLE} uses windows; type Message = class txt : string; constructor create(s:string); procedure print; end; constructor Message.Create(s:string); begin txt := s end; procedure Message.print; begin writeln(txt) end; var m : Message; begin m := Message.Create('Hello world'); m.print() end.