LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use templates in LabWindows as we use in C++

Hello,
        Can we use templates in LabWindows CVI as we use in C++.i.e., if we define class with template we can pass variables of any datatype to it or if we define a function with template datatype as argument  then it will accept variable with any datatypes.Hence  there is no need to write same function more than once only becoz its argument's datatype differ. 
Expecting Reply,
 
Rgds,
   Mala 
0 Kudos
Message 1 of 4
(3,332 Views)
Hi Mala,

LabWindows/CVI is pure ANSI C and so it doesn't understand any C++ concepts. Check out this forum post which discusses what options you have of mixing CVI with C++.

Best Regards,
Jonathan N.
National Instruments
Message 2 of 4
(3,321 Views)
Without mixing with C++, you can do a 'dirty' template by using a #define in
some cases. For instance:

#define NUM int
//#define NUM float

NUM FunctionAdd(NUM a, NUM b) {
return a+b;
}

But this method cracks down fairly quickly...
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 4
(3,281 Views)
Vava -

Templates in C++ provide static parametric polymorphism Smiley Wink

They are similar to generics in Ada.  Java and C# implement generics also. 

But not C89 that we have in CVI.  Or C99 either, as best as I can tell.

You can use C# and C++ with CVI as noted, but I don't think there's any way to use Java or Ada.

Menchar
0 Kudos
Message 4 of 4
(3,271 Views)