c++Öе÷ÓÃruby´úÂë
#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
VALUE * values = (VALUE *) args;
VALUE summer = values[0];
VALUE max = values[1];
return rb_funcall(summer,id_sum,1,max);
}
static VALUE protected_sum(VALUE summer, VALUE max)
{
int error; VALUE args[2];
VALUE result;
args[0] = summer;
args[1] = max;
result = rb_protect(wrap_sum,(VALUE)args, &error);
return error ? Qnil:result;
}
int main()
{
int value;
int *next = Values;
ruby_init();
ruby_init_loadpath();
ruby_script("embedded");
rb_require("sum.rb");
VALUE summer = rb_class_new_instance(0,0,rb_const_get(rb_cObject,rb_intern("Summer")));
id_sum = rb_intern("sum");
while (value = *next++)
{
VALUE result = protected_sum(summer,INT2NUM(value));
if (NIL_P(result))
{
printf("Sum to %d doesn't compute!\n",value);
}
else
printf("Sum to %d is %d\n",value,NUM2INT(result));
}
ruby_finalize();
}
Ïà¹ØÎĵµ£º
SleekEngine
Ëæ׿ÆËã»úÓ²¼þµÄ¿ìËÙ·¢Õ¹£¬10ÄêÇ°ÒòΪËÙ¶ÈÎÊÌâ¶ø±»Ú¸²¡µÄJavaÏÖÔÚ³ÉÁ˼ÆËã»úÁ÷ÑÔÓïÑÔÖеÄÀϴ󣬵«ÊÇËüÈ´ÈÔ±»ÈÏΪ¸´ÔÓ±¿ÖØ£¬½ü¼¸ÄêÀ´¶¯Ì¬Óï
ÑÔÈ´ÓкóÀ´¸ÏÉϵÄÇ÷ÊÆ£¬ÕÆÎÕÒ»ÃŶ¯Ì¬ÓïÑÔ³ÉÁ˳ÌÐòÔ±ÐèÒª¿¼ÂǵÄÊÂÒË¡£ ½üÆÚ½Ó´¥Á˼¸ÖÖÁ÷ÐеĶ¯Ì¬ÓïÑÔPython, Ruby,
Groovy£¬ËüÃÇÏà±È¾²Ì¬ÓïÑÔJava/C++À´Ëµ£¬´óÎ ......
Data Type Ranges
C/C++ recognizes the types shown in the table below.
Type Name Bytes Other Names Range of Values
&nb ......
JavaÓëC++×î´óµÄ²»Í¬µÄ£¬JavaÍêÈ«ÊÇÃæÏò¶ÔÏóµÄ£¬ÊÇÓÉÀ๹³ÉµÄ£¬¶øC++ÊÇÓɶÔÏóÓë¹ý³Ì×é³É¡£
1¡¢Â·¾¶£º
Java°üÀ¨Ò»¸ö°üpackage,C++ûÓУ»
2¡¢ÒýÈëÀà
java import.*.*; C++ include ""';
3¡¢Ô¤¶¨Ò壬
C++°üÀ¨Ô¤¶¨Ò壬Java²»°üÀ¨
4¡¢½á¹¹
C++°üÀ¨½á¹¹£¬JavaÖ»°üÀ¨À࣬½á¹¹Ìå¿ÉÒÔת»¯ÎªÀà¡£
5¡¢ÀàÃûÓëÎļþÃû
Jav ......
±¾ÎĽéÉÜÁËRuby on RailsµÄÏêϸ°²×°²½Öè¡£ÎÄÖÐʹÓõÄRuby on Rails°æ±¾ÊÇ1.8.6-26¡£°²×°RubyÖ®ºó°²×°Rails£¬È»ºó¾Í¿ÉÒÔ´´½¨WebÓ¦Ó㬲¢ÔÚ±¾µØ²âÊÔÁË¡£
1¡¢°²×°ruby
²»ÓÃ˵ ÊÇÏÂÔØ°²×°°ü£ºhttp://rubyforge.org/frs/?group_id=167£¬×¢Òâ°æ±¾---º¦È˲»Ç³£¬ºóÃæ»á˵µ½£¬ÎÒϵÄÊÇ1.8.6-26
×°Íêºó£¬¿ÉÒÔÓÃruby -v ²âÊÔÊÇ·ñ° ......