#include <iostream>
#include "class.h"
#include <iomanip>
#include <new.h>
using namespace std;
//enum ay{a, b};
class Size
{
enum ay{a, b}; //枚举常量不占对象空间,编译时就计算好了值
//enum ay s1;
};
void p_print(int x, int y) //函数形参计算,从右向左
{
cout<<x<<" "<<y<<endl;
}
int handle_program_memory_depletion( size_t )
{
// Your code
return 0;
}
int main()
{
int i = 0, j = 1;
if (i++||j++)//里说是从右向左,。。错了!
{
cout<<i<<" "<<j<<endl;
}
p_print(i=i+1, j= i+1);
Size am;
cout<<sizeof(am)<<endl;
//enum ay s1 = a;
_set_new_handler( handle_program_memory_depletion );
int *pi = new int[9000000000];
//size[100][200]
Size **op = new Size*[100]; //op 是指向指针数组的指针,非连续存储,但200可以是变量
for (int k = 0 ; k<100; k++)
{
op[k] = new Size[200];
}
for (k = 0 ; k<100; k++)
{
delete[] op[k];
}
delete[] op;
const int nm = 200;
int nn = 200;
int ni = 100;
Size (*kp)[200] = new Size[100][200];//kp 为指向数组的指针、优点调用直观连续,但100\200必须是已知的常量
Size (*pp)[nm] = new Size[100][nm];//ok
//Size (*po)[nn] = new Size[100][nn];//err
op[1][1];
kp[1][1];
delete []kp;
delete[] pp;
Size **opp = new Size*[nn]; //op 是指向指针数组的指针,非连续存储,但100\200可以是变量
for (int h= 0 ; h<100; h++)
{
opp[h] = new Size[nn];
}
for (k = 0 ; k<100; k++)
{
delete[] opp[k];
}
delete[] opp;
Size* ga = new Size[ni*nn]; //调用不直观,但连续,但100\200可以是变量
ga[i*nn+j];
delete[] ga;
。。。
return 0;
}