Problem calling template functions

How do I call these functions from Mechanical.h???

Mechanical.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef MECHANICAL_H_
#define MECHANICAL_H_

class statics { public:

template<class T> struct Inertia_types {
	T Rec(T _x, T _y);
	T Tri(T _x, T _y);
	void Entity(T _x[], T _y[]); 
} momentOfInertia;

} Static_func;

#endif 


Mechanical.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <math.h>
#include "Mechanical.h"

template<class T> T statics::Inertia_types<T>::Rec(T _x, T _y)
{
	double _val = (1.0/12) * _x * pow(_y, 3);
	return _val;
}
template<class T> T statics::Inertia_types<T>::Tri(T _x, T _y)
{
	double _val = (1.0/36) * _x * pow(_y, 3);
	return _val;
}
template<class T> void statics::Inertia_types<T>::Entity(T _x[], T _y[])
{
	double _val = 0;
}


//////////////////////////////////////
#include <iostream>
using namespace std;

int main()
{
	float i = 1;
	double n = 1;

	//cout << Static_func.momentOfInertia.Rec(n,n) << endl;
	//cout << Static_func.momentOfInertia.Tri(n,n) << endl;
	system("pause");
	return 0;
}


Im trying to create templated functions which I can apply all data types to except for strings and other types such as wchar. Am I also writing these correctly? This is my first attempt ever doing this so ALL help is greatly appreciated!
closed account (Dy7SLyTq)
try making the struct outside of it and making a pointer to it in the class
Topic archived. No new replies allowed.