请看下面的代码
计算器.h
#pragma once
#include <iostream>
template<class T>
class Calculator
{
public:
Calculator(void);
~Calculator(void);
void add(T x, T y)
{
cout << (x+y) << endl;
}
void min(T x, T y)
{
cout << (x-y) << endl;
}
void max(T x, T y)
{
cout << (x*y) << endl;
}
void dev(T x, T y)
{
cout << (x/y) << endl;
}
};
主文件
#include "Calculator.h"
using namespace std;
int main()
{
Calculator<double> c;
c.add(23.34,21.56);
system("pause");
return 0;
}
当我运行此代码时,出现以下错误。我对类模板不太熟悉。请帮忙!
1>------ Build started: Project: TemplateCalculator, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\yohan\documents\visual studio 2010\Projects\TemplateCalculator\Debug\TemplateCalculator.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========