版本1和2间的区别
于2007-05-13 23:13:20修订的的版本1
大小: 381
编辑: czk
备注:
于2007-05-13 23:16:48修订的的版本2
大小: 675
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 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++

   1 #include <iostream>
   2 #include <string>
   3 using namespace std;
   4 
   5 class Message {
   6 private:
   7    string txt;
   8 public:
   9    Message(string s){ txt = s;}
  10    void Print() const { cout << txt;}
  11 };
  12 
  13 int main()
  14 { 
  15    Message M("Hello world");
  16    M.Print();
  17 }

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.

程序设计语言 (2020-04-26 08:51:16由czk编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.