マイクロソフトの資料から引用。
The __thiscall calling convention is used on member functions and is the default calling convention used by C++ member functions that do not use variable arguments. Under __thiscall, the callee cleans the stack, which is impossible for vararg functions. Arguments are pushed on the stack from right to left, with the this pointer being passed via register ECX, and not on the stack, on the x86 architecture.
The __thiscall calling convention is used on member functions and is the default calling convention used by C++ member functions that do not use variable arguments.
__thiscall呼び出し規約は、メンバー関数に利用され、可変長でない引数をとらないメンバー関数でデフォルトの呼び出し規約です。
Arguments are pushed on the stack from right to left, with the this pointer being passed via register ECX, and not on the stack, on the x86 architecture.
x86互換機では、引数は右から左にスタックにプッシュし、thisポインタはスタックではなくECXレジスタを通して渡されます。
vararg member functions use the __cdecl calling convention.
可変長の引数をとるメンバ関数は__cdecl呼び出し規約を利用します。
All function arguments are pushed on the stack, with the this pointer placed on the stack last
全ての引数はスタックに積まれ、thisポインタは最後にスタックに詰まれます。
(訳注:__cdeclは呼び出し側がスタックを綺麗にする。引数は右から左へ積む。)
class CSuper{public: virtual int Get() = 0;};
class CSub : public CSuper{private: int i; public: CSub(int v){i = v;} ~CSub{} virtual int Get(){return i}};
int main(int argc, char **argv){
FILE *in = fopen("input.txt", "r");
FILE *out = fopen("output.txt", "w");
char buff[1024];
int m; //出題元の値
int b; //バッファ
int c; //釣り
int num = 0; //枚数
if(!in || !out) return -1;
fgets(buff, sizeof(buff), in);
m = atoi(buff);
c = 1000 - m;
if(b = c / 500){
num += b;
c = c - b * 500;
}
if(b = c / 100){
num += b;
c = c - b * 100;
}
if(b = c / 50){
num += b;
c = c - b * 50;
}
if(b = c / 10){
num += b;
c = c - b * 10;
}
if(b = c / 5){
num += b;
c = c - b * 5;
}
if(b = c / 1){
num += b;
c = c - b * 1;
}
class ISub1 : virtual public IClass{
public:
virtual
~ISub1(){}
int m_v1;
virtual
int Get1() = 0;
};
class ISub2 : virtual public IClass{
public:
virtual
~ISub2(){}
int m_v2;
virtual
int Get2() = 0;
};
class CSub : public ISub1, public ISub2{
public:
virtual
int Get1(){
return m_v1;
}
virtual
int Get2(){
return m_v2;
}
virtual
int Get(){
return m_1;
}
};