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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:38:50+00:00 2026-05-14T04:38:50+00:00

I am just starting out C++, so sorry if this is a dumb question.

  • 0

I am just starting out C++, so sorry if this is a dumb question. I have a class Braid whose members are vectors. I have not written an assignment operator. When I do a lot of assignments to an object of the type Braid, I run into memory issues :-

 0  0xb7daff89 in _int_malloc () from /lib/libc.so.6
#1  0xb7db2583 in malloc () from /lib/libc.so.6
#2  0xb7f8ac59 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6
#3  0x0804d05e in __gnu_cxx::new_allocator<int>::allocate (this=0xbf800204, __n=1)
    at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/ext/new_allocator.h:89
#4  0x0804cb0e in std::_Vector_base<int, std::allocator<int> >::_M_allocate (this=0xbf800204, __n=1)
    at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:140
#5  0x0804c086 in _Vector_base (this=0xbf800204, __n=1, __a=...)
    at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:113
#6  0x0804b4b7 in vector (this=0xbf800204, __x=...)
    at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:242
#7  0x0804b234 in Braid (this=0xbf800204) at braid.h:13
#8  0x080495ed in Braid::cycleBraid (this=0xbf8001b4) at braid.cpp:191
#9  0x080497c6 in Braid::score (this=0xbf800298, b=...) at braid.cpp:251
#10 0x08049c46 in Braid::evaluateMove (this=0xbf800468, move=1, pos=0, depth=2, b=...)

I suspect that these memory issues are because the vectors are getting resized. What I want to know is whether objects of type Braid automatically expand when its members expand? the code I am writing is really long so I will post the section which is causing the problems. Here is the relevant section of the code :-

class Braid 
{
private :
  vector<int> braid; //Stores the braid.  
  int strands;
  vector < vector<bool> > history; 
  vector < vector<bool> > CM;    
public :
  Braid () : strands(0) {}
  Braid operator * (Braid);
  Braid* inputBraid(int,vector<int>);
  int printBraid();
  int printBraid(vector<vector<int>::iterator>);
  vector<int>::size_type size() const;
               .....
               .....
}

Here is the function which causes the issue :-

int Braid::evaluateMove(int move,int pos,int depth,Braid b)
{
 int netscore = 0;
 Braid curr(*this);
 curr = curr.move(move,pos);
 netscore += curr.score(b);

 while(depth > 1)
 {
   netscore += curr.evaluateMove(1,0,depth,b);
   netscore += curr.evaluateMove(2,0,depth,b);
   for(int i = 0; i < braid.size();++i)
   {
    netscore += curr.evaluateMove(3,i,depth,b);
    netscore += curr.evaluateMove(4,i,depth,b);
    netscore += curr.evaluateMove(5,i,depth,b);
    curr = curr.cycleBraid();
    netscore += curr.evaluateMove(6,0,depth,b);
   }
   --depth;
 }
 return netscore;
}
  • 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-05-14T04:38:51+00:00Added an answer on May 14, 2026 at 4:38 am

    Another problem :

    while(depth > 1)
    {
      netscore += curr.evaluateMove(1,0,depth,b);
      ....
      --depth;
    }
    

    causes endless recursion when depth >1

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

Sidebar

Related Questions

Sorry for the rookie question, as I'm just starting out with C#. I have
Sorry if this is quite noobish to you, but I'm just starting out to
Sorry if my question is too simple, I am just starting out with CGI...
Just starting out with subversion, have set up repos for 3 current projects and
Just starting out, this should be a simple one but I haven't been able
I'm just starting out with Core Data and I have an iPhone Core Data
Sorry if it's a silly question , but I'm just starting learning GWT and
Just starting out with C#, so this may be overly simple that I keep
I just started using java so sorry if this question's answer is obvious. I
I have a question about regex/Python. Sorry if this topic has been discussed millions

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.