T
thinktwice
can't compile the file below, i have remarked the error line, if i
delete that line , it just pass throgh the compile, can anyone tell me
why?
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
#define pTC static_cast<TClass*>(this);
template<class TClass>
class Base
{
public :
void Test(){
pTC->Hello();
}
void Test(int i){
cout<<"base";
}
};
template<class TClass>
class Derived: public Base<TClass>
{
public :
void Test(){
pTC->Hello(); //error C2143: syntax error : missing ';' before '->'
cout<<"Derived";
}
virtual void Hello(){
cout<<"";
}
};
class Final : public Derived<Final>
{
public:
void Hello(){
cout<< "final";
}
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
Final f;
std::vector<int> vec;
f.Test();
return 0;
}
delete that line , it just pass throgh the compile, can anyone tell me
why?
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
#define pTC static_cast<TClass*>(this);
template<class TClass>
class Base
{
public :
void Test(){
pTC->Hello();
}
void Test(int i){
cout<<"base";
}
};
template<class TClass>
class Derived: public Base<TClass>
{
public :
void Test(){
pTC->Hello(); //error C2143: syntax error : missing ';' before '->'
cout<<"Derived";
}
virtual void Hello(){
cout<<"";
}
};
class Final : public Derived<Final>
{
public:
void Hello(){
cout<< "final";
}
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
Final f;
std::vector<int> vec;
f.Test();
return 0;
}