📄 main.cpp
字号:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
template<class T>
struct X_base {
typedef T instantiated_type;
};
template<class A, class B>
struct X : public X_base<B> {
bool operator()( const instantiated_type& i ) {
return ( i != instantiated_type() );
}
// ... more stuff ...
};
template <class T>
class SomethingForEveryone {
public:
T member;
};
template <int MaxPrice>
class PriceController {
public:
int Price;
void TestPrice() {
if (Price > MaxPrice) {
cout << "Too expensive" << endl;
}
}
};
int main(int argc, char *argv[])
{
SomethingForEveryone<int> JustForMe;
JustForMe.member = 2;
cout << JustForMe.member << endl;
const int FredMaxPrice = 30;
PriceController<FredMaxPrice> FredsToaster;
FredsToaster.Price = 15;
FredsToaster.TestPrice();
PriceController<FredMaxPrice> FredsDrawingSet;
FredsDrawingSet.Price = 45;
FredsDrawingSet.TestPrice();
const int JulieMaxPrice = 60;
PriceController<JulieMaxPrice> JuliesCar;
JuliesCar.Price = 80;
JuliesCar.TestPrice();
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -