C++ Undefined Reference to... using Templates
Hello Everyone! I'm studying C++ and when I try to compile all the knowledge learned from the c++ course that I finished here in sololearn, in one single and simple problem I stuck "HEHEHE". thats my Three files... Number 1: Calculadora.h (Calculator) ******************************************************************** #ifndef CALCULADORA_H #define CALCULADORA_H template<typename T> class Calculadora { public: //Constructor Calculadora(){} //Funções T somar( T, T ); T subtrair( T, T ); T multiplicar( T, T ); T dividir( T, T ); void mostrarResultado( T ); }; #endif ******************************************************************** Number 2: Calculadora.cpp ******************************************************************** #include<iostream> #include"Calculadora.h" template <typename T> T Calculadora<T>::somar(T n1, T n2) { return (n1 + n2); } template <typename T> T Calculadora<T>::subtrair(T n1, T n2) { return (n1 - n2); } template <typename T> T Calculadora<T>::multiplicar(T n1, T n2) { return (n1 * n2); } template <typename T> T Calculadora<T>::dividir(T n1, T n2) { return (n1 / n2); } template <typename T> void Calculadora<T>::mostrarResultado(T res) { std::cout << res << std::endl; } ******************************************************************** Number 3: main.cpp ******************************************************************** #include <iostream> #include "Calculadora.h" int num1 = 0, num2 = 0; int main() { Calculadora <int> cObj; std::cout << "Primeiro Valor: "; std::cin >> num1; std::cout << std::endl; std::cout << "Segundo Valor: "; std::cin >> num2; std::cout << std::endl; std::cout << "Resultado da Soma = " << cObj.somar(num1, num2) << std::endl; std::cout << "Resultado da Subtração = " << cObj.subtrair(num1, num2) << std::endl; std::cout << "Resultado da Multiplicação = " << cObj.multiplicar(num1, num2) << std::enl;