Please don't put "using namespace" inside header files. This can cause
conflict with code that includes the header but doesn't expect to get
the namespace.
typedef int MYINT;
void sum(MYINT a, MYINT b);
example.cpp #include"example.h"
void sum(MYINT a, MYINT b)
{
MYINT c;
c=a +b;
cout<<c;
}
example.i
%module example
%{ #include"example.h"
extern void sum(MYINT a, MYINT b);
%}
But it is giving me error undefined MYINT when i'm trying to compile
In Ruby, variables do not have types (all variables are references to
Objects, and the type of the Object is determined dynamicaly). If you
write instead:
a=10
b=20
Example.sum(a,b)
I think it should work.
Note that you don't need to terminate your lines with a semicolon in
Ruby.
Paul
···
On Wed, Mar 19, 2008 at 07:24:46PM +0900, Abhi Us wrote:
Please don't put "using namespace" inside header files. This can cause
conflict with code that includes the header but doesn't expect to get
the namespace.
But it is giving me error undefined MYINT when i'm trying to compile
In Ruby, variables do not have types (all variables are references to
Objects, and the type of the Object is determined dynamicaly). If you
write instead:
a=10
b=20
Example.sum(a,b)
I think it should work.
Note that you don't need to terminate your lines with a semicolon in
Ruby.
Paul
Hi i got ur point that ruby do not have types. Then suppose if i have
user defined data type for e.g
map<int,string> MYmap;
is present in C++ code.How should i create the instances of it in ruby.
Can i write like
m1.insert(1,"amey")
and it will be treated as the map which i have defined..
···
On Wed, Mar 19, 2008 at 07:24:46PM +0900, Abhi Us wrote:
On Thu, Mar 20, 2008 at 02:20:17PM +0900, Abhi Us wrote:
Hi i got ur point that ruby do not have types. Then suppose if i have
user defined data type for e.g
map<int,string> MYmap;
is present in C++ code.How should i create the instances of it in ruby.
Can i write like
m1.insert(1,"amey")
and it will be treated as the map which i have defined..