I have a simple class aClass
:
class aClass
{
public:
aClass(int size)
{
condition = new bool[size];
}
~aClass()
{
delete condition;
}
bool getCondition(int i) const
{
return condition[i];
}
void setCondition(bool* condition, int i)
{
*(this->condition + i) = *condition;
}
private:
bool* condition;
};
In fact I defined a bool pointer and using constructor to allocate memory.
#include <iostream>
#include "aClass.h"
using namespace std;
int main()
{
aClass tempVar(10);
bool *pC;
for (int i = 0; i < 10; i++)
{
*pC = 0;
tempVar.setCondition(pC, i);
}
for (int i = 0; i < 10; i++)
{
cout << tempVar.getCondition(i);
}
return 0;
}
I do not know what is the problem in this code.
I used gcc version 4.6.3 to compile the code.