Added (then fixed) templates with multiple parameters for both classes and functions!
This commit is contained in:
1
tests/functionMultipleTemplateTest.expected_results
Normal file
1
tests/functionMultipleTemplateTest.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
22.141590
|
||||
13
tests/functionMultipleTemplateTest.krak
Normal file
13
tests/functionMultipleTemplateTest.krak
Normal file
@@ -0,0 +1,13 @@
|
||||
import io;
|
||||
|
||||
template <T,J> void addAndPrint(T a, J b) {
|
||||
print(a+b);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
addAndPrint<int,float>(10,12.14159);
|
||||
print("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -11,4 +11,4 @@ int main() {
|
||||
print("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
4
tests/simpleObjectMultipleTemplateTest.expected_results
Normal file
4
tests/simpleObjectMultipleTemplateTest.expected_results
Normal file
@@ -0,0 +1,4 @@
|
||||
a: 24
|
||||
b: Hello World
|
||||
a: Pi incoming
|
||||
b: 3.14159 - Fooled you! txt pi. C is being weird with floats. Not a Kraken problem. Ahh Well.
|
||||
30
tests/simpleObjectMultipleTemplateTest.krak
Normal file
30
tests/simpleObjectMultipleTemplateTest.krak
Normal file
@@ -0,0 +1,30 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef template <T,J> TemplateTest {
|
||||
T a;
|
||||
J b;
|
||||
void print() {
|
||||
print("a: ");
|
||||
print(a);
|
||||
print("\n");
|
||||
print("b: ");
|
||||
print(b);
|
||||
print("\n");
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
TemplateTest<int, char*> test;
|
||||
TemplateTest<char*, char*> test2;
|
||||
test.a = 24;
|
||||
test.b = "Hello World";
|
||||
test2.a = "Pi incoming";
|
||||
test2.b = "3.14159 - Fooled you! txt pi. C is being weird with floats. Not a Kraken problem. Ahh Well.";
|
||||
|
||||
test.print();
|
||||
test2.print();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user