1: include "std"; 2: struct gauss = { 3: x : int; 4: y : int; 5: } 6: 7: proc _set ( lhs: &gauss, rhs: gauss ) 8: { 9: (*lhs).x = rhs.x; 10: (*lhs).y = rhs.y; 11: } 12: 13: fun add (a:gauss, b:gauss): gauss = { 14: return gauss(a.x+b.x, a.y+b.y); 15: } 16: 17: fun mul (a:gauss, b:gauss): gauss = { 18: return gauss(a.x+b.x - a.y+b.y, a.x*b.y + a.y*b.x); 19: } 20: 21: fun mkgauss (a:int,b:int):gauss = { return gauss(a,b); } 22: fun real (z:gauss):int = { return z.x; } 23: fun imag (z:gauss):int = { return z.y; } 24: 25: proc print(z:gauss) { 26: print "("; 27: print (real z); 28: print ", "; 29: print (imag z); 30: print ")"; 31: } 32: 33: fun sqr(z:gauss):gauss = { 34: return z * z; 35: } 36: 37: fun norm(z:gauss): int = { 38: return 39: real z * real z + imag z * imag z 40: ; 41: } 42: 43: val z1 = mkgauss(1,2); 44: val z2 = z1 + z1; 45: val z3 = sqr z2; 46: val n = norm z3; 47: print z1; endl; 48: print z2; endl; 49: print z3; endl; 50: print n; endl; 51:
As you can guess, the whole of the program could have been written in C++ rather than Felix.
It's up to you to choose what parts of your Felix program are written directly in C++, and which parts are written in Felix: since Felix is a C++ code generator, it all ends up as C++ anyhow.
Usually, you'll write Felix, except when you have an existing code base containing useful types you need to work with.