considering this code i put a bp at the end of roll(int n) and i had data in values array and i put another one at the end of print and there was no data in the array.Why do I get this error: CXX0069: Error: variable needs stack frame?
die.h
#ifndef DIE_H
#define DIE_H
#include<iostream>
#include<time.h>
using namespace std;
class Die
{
private:
int number;
int values[6][2];
void roll();
public:
Die();
void Roll(int n);
int getNumber()const{return number;}
void printLastValue();
void printApearences();
~Die(){}
};
#endif
die.cpp
#include"die.h"
#include<iostream>
#include<time.h>
using namespace std;
Die::Die()
{
srand(static_cast<int>(time(NULL)));
number=0;
for(int j=0;j<6;j++)
{
values[j][0]=j+1;
values[j][1]=0;
}
}
void Die::roll()
{
number=1+rand()%6;
}
void Die::printLastValue()
{
cout<<number<<endl;
}
void Die::Roll(int n)
{
for(int j=0;j<6;j++)
{
values[j][0]=j+1;
values[j][1]=0;
}
for(int i=0;i<n;i++)
{
roll();
(values[number-1][1])++;
}
}
void Die::printApearences()
{
for(int i=0;i<6;i++)
{
cout<<values[i][0]<<" : "<<cout<<values[i][1]<<endl;
}
}
main.cpp
#include"die.h"
#include<iostream>
using namespace std;
int main()
{
Die d;
d.Roll(5);
d.printApearences();
}