“如果说c语言给了你足够的绳子吊死自己,那么c++给的绳子除了够你上
吊之外,还够绑上你所有的邻居,并提供一艘帆船所需的绳索。”
——匿名
悲哀的是,学习c++成了每个计算机科学家和严肃程序最为有利可图的投资。它
迅速成为简历中必不可少的一行。在过去的今年中,我们见过不少c++程序员,
他们能够用c++写出不错的代码,不过...
....他们憎恶它。
程序员进化史
初中/高中
10 print "hello world"
20 end
大学一年级
program hello(input, output);
begin
writeln(hello world);
end.
大学四年级
(defun hello ()
(print (list hello world)))
刚参加工作
#include
main (argc, argv)
int argc;
char **argv; {
printf ("hello world!\n";
}
老手
#include
const int maxlen = 80;
class outstring;
class outstring {
private:
int size;
char str[maxlen];
public:
outstring() { size=0; }
~outstring() { size=0; }
void print();
void assign(char *chrs);
};
void outstring::print() {
int in;
for (i=0; icout << str;
cout << "\n";
}
void outstring::assign(char* chrs) {
int i;
for (i=0; chars!=\0; i++)
str = chrs;
size=i;
}
main (int argc, char **argv) {
outstring string;
string.assign("hello world!";
string.print();
}
超级BT:
interface messagestrategy {
public void sendmessage();
}
abstract class abstractstrategyfactory {
public abstract messagestrategy createstrategy(messagebody mb);
}
class messagebody {
object payload;
public object getpayload() {
return payload;
}
public void configure(object obj) {
payload = obj;
}
public void send(messagestrategy ms) {
ms.sendmessage();
}
}
class defaultfactory extends abstractstrategyfactory {
private defaultfactory() {
;
}
static defaultfactory instance;
public static abstractstrategyfactory getinstance() {
if (instance == null)
instance = new defaultfactory();
return instance;
}
public messagestrategy createstrategy(final messagebody mb) {
return new messagestrategy() {
messagebody body = mb;
public void sendmessage() {
object obj = body.getpayload();
system.out.println((string) obj);
}
};
}
}
public class helloworld {
public static void main(string[] args) {
messagebody mb = new messagebody();
mb.configure("hello world!";
abstractstrategyfactory asf = defaultfactory.getinstance();
messagestrategy strategy = asf.createstrategy(mb);
mb.send(strategy);
}
}
..
老板
“乔治,我需要一个能打印hello world!的程序”
我上次看见一个用遗传算法输出一个"hollo world!"的程序,300多行吧.天知道是想干什么,无敌BT!
哪真的是超级BT了.
笑一笑,十年少
呵呵,有意思~~
有意思 想不到啊 hello world 也能这样写 呵呵!