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 8723501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:38:39+00:00 2026-06-13T07:38:39+00:00

Am trying to get myself used to working with dynamic arrays in c++ and

  • 0

Am trying to get myself used to working with dynamic arrays in c++ and now am stuck for like the tenth time today. The program compiles fine, but after taking inputs it gives the stack overflow error, and I have provided functionality to delete the heap in my constructor, I assumed I had an uninitiated variable but i really cant find it. Am hoping you guys can help me check it out. This is the code:

#include<string>
#include<cmath>
#include<sstream>
using namespace std;
#include"Calc.h"
#include<iostream>
using namespace std;

Calc::Calc(int a, int*b){
length=a;
ar=b;
AR =new int*[length];


for (int i=0; i<length;i++){
    AR[i] = new int [ar[i]]();
    }

for (int i = 0; i < length; i++)
    delete[] AR[i];
    };

Calc::~Calc(){};

int Calc::solveFor(int m0, int n0){
int ans=0;
if (m0=0) {ans =n0+1; AR[m0][n0]=ans; return n0+1;}
if (n0=0) {ans= solveFor(m0-1,1); AR[m0][n0]=ans;return ans;}
else {ans=solveFor(m0-1, solveFor(m0, n0-1));AR[m0][n0]=ans; return ans;}
};



void Calc::getSolved(){
for(int i=0; i<=length; i++){cout<<endl;
    for (int j=0; j<ar[i]; j++)
        cout<<"ACK ["<<i<<","<<j<<"]="<<AR[i][j]<<"  ";}
    cout<<endl;


};

The Run.cpp:

#include<iostream>
#include<string>
#include "Calc.h"

using namespace std;

int main() {
int m;
int n;
int v[6]= {7, 7, 7, 7, 7, 7};
Calc XXX(6, v);
cin>>m;
cin>>n;


XXX.solveFor(m,n);
XXX.getSolved();

  return 0;
}

thanks in advance.

  • 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-13T07:38:40+00:00Added an answer on June 13, 2026 at 7:38 am

    One issue I can see in Calc::solveFor is you are using the assignment operator in place of equality:

    if (m0=0)
    

    should be

    if (m0==0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to get familiarize myself with matrices in Ruby. I am trying
I'm trying to get a certificate for myself, paying $200 to get it. Before
I've been googling & trying to get this myself but can't quite get it...
When working on complex problems, I find myself trying all sorts of solutions and,
I'm a new programmer trying to teach myself C++ and OOP. Right now I'm
As a small project to get myself used to some more iPhone elements I've
I am trying to have a program that uses multiple forks. I used this
I have been trying to learn and get used to version control, more specifically
I am trying to get a list of mutual friends of myself and another
When working on developing new software i normally get stuck with the redundancy vs

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.