1.) How did you find out the time? --> use GetTickCount() in windows.h.
2.) then show me the exact code which you profiled with the profiled output --> see the code below.
main.cpp
Code:
#include <iostream>
#include <windows.h>
#include <iostream>
#include "cBild.h"
const int DIM1 = 768;
const int DIM2 = 1024;
int main()
{
DWORD zeit1=GetTickCount();
cBild data;
std::vector <cBild> Vector;
int i;
DWORD zeit2;
for (i=0;i<5;i++)
{
zeit2 = GetTickCount();
Vector.push_back(data);
std::cout << "\ttime: " << (double)(GetTickCount()-zeit2)/1000 << "s" << std::endl;
}
return 0;
}
cBild.h
Code:
#include <iostream>
#include <ctime>
#include <vector>
#pragma once
extern const int DIM1;
extern const int DIM2;
class cPixel
{
public:
cPixel(void)
{
for (int i=0;i<3;i++)
itsRGB[i] = 0;
}
void SetRGB (int type, int val)
{itsRGB[type] = val;}
int GetRGB (int type) const
{return itsRGB[type];}
private:
int itsRGB[3]; //Red,Green,Blue
};
class cBild
{
public:
cBild(void)
{
itsVal = new cPixel *[DIM1];
for (int i=0;i<DIM1;i++)
itsVal[i] = new cPixel [DIM2];
}
~cBild(void)
{
for (int i=0;i<DIM1;i++)
delete[] itsVal[i];
delete[] itsVal;
}
cBild (const cBild &right);
const cBild& operator=(const cBild &right);
private:
cPixel **itsVal;
};