Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:21:40+00:00 2026-06-14T17:21:40+00:00

considering this code i put a bp at the end of roll(int n) and

  • 0

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();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:21:41+00:00Added an answer on June 14, 2026 at 5:21 pm

    What exactly is this:

    cout<<values[i][0]<<" : "<<cout<<values[i][1]<<endl;
    

    Specifically, why are you trying to extract cout to cout? Copy/paste can be a ruthless wench. Pretty sure you want:

    cout << values[i][0] <<" : "<< values[i][1] << endl;
    

    Next, your header declarations are quite-convoluted.

    • Do NOT place using namespace std in any of your header files. For information on why, refer this question and its various discussions. If your fingers tire of typing std:: there are some alternatives, but in-general slurping an entire namespace (especially one as large as std) can cause unintended consequences. The linked question is worth a review.
    • Do not bring #include‘s into a header unless the content therein is dependent on it (Die.h needs nothing you’re #include‘ing, for example).
    • List your headers ahead of system headers, including in your headers, to ensure you do not code an implicit include that your header by-itself doesn’t fulfill.
    • Include standard library C++ headers if you’re compiling in C++ (use <cstdio>, <cstdlib>, <ctime>, etc.

    Applying the above your code becomes:

    Die.h

    #ifndef DIE_H
    #define DIE_H
    
    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 (top of file, code eliminated for brevity)

    #include "die.h"
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    

    main.cpp (top of file, code eliminated for brevity)

    #include "die.h"
    

    The last one traditionally contains <iostream> as well, but you don’t actually need it in your code as it is written.


    You’re static cast to int for sending time(NULL) as the random seed is not correct. The srand(unsigned int seed); API takes an unsigned int as the seed, not an int. Change your seeding to be

    srand(static_cast<unsigned int>(time(NULL)));
    

    I’d start with those, specifically the first two suggestions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering this code with 3 differents function call semantics: void f(void){ puts(OK); } int
Considering this code: std::vector<myObject*> veryLargeArray; for (int i = 0; i < veryLargeArray.size(); ++i)
Considering this article Developing a MVC component for Joomla , following is the code
I apologize if this code looks a bit like a mess (considering the length);
given this code: class Foo def bar return Bar.new end end class Bar ...
Considering this code (and using SQLAlchemy 0.7.7): class Document(Base): __tablename__ = 'document' __table_args__ =
Considering this code: architecture synth of my_entity is signal a : std_logic; begin a
Considering this code, can I be absolutely sure that the finally block always executes,
Considering this code: <telerik:RadGridView ItemsSource={Binding SearchResults} RowDetailsVisibilityMode=VisibleWhenSelected> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header=First Name DataMemberBinding={Binding FirstName} />
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.