mitrmkar 1,056 Posting Virtuoso

i am facing problems of destructor in the following code.destructor is not working

The memory allocation is one byte off, you need to allocate an additional byte for the null terminator placed there by strcpy() , so

len = strlen(str) + 1;

FYI, sizeof(char) is always one (1), so you can drop sizeof(char) altogether.

In the constructor, len is rather 1 than 0, though this does not affect the program as of now.

Then last but not least, it's a good practice to check whether the memory re/allocation succeeds. If they don't, the program crashes.

[EDIT]
Since this is C++, maybe rewrite the program using new/delete or std::string .

mitrmkar 1,056 Posting Virtuoso

I tried to move the entire visio contents:
/VC/bin/
to the same folder

I suppose you mean Visual Studio instead of 'visio', right?

Anyway, consider that upon install, the VS tools do modify the system by modifying environment variables (and being MS tools, maybe system registry etc.) in order to locate things at run-time. So, moving the tools might not be a good idea in the first place.

Then again, Visual Studio comes with a batch file vcvarsall.bat, which configures the environment (via other .bats) so that the binaries find what's needed. So maybe locate this vcvarsall.bat, which is usually in the VS root install dir, and see what you can do in terms of re-configuring the paths and such. It may even work.

mitrmkar 1,056 Posting Virtuoso

Here is what I have so far. Suggestions??

Compile the code and start working through the errors/warnings from top to down. Once you think you have solved/fixed a specific error, re-compile and see the results, i.e. don't try to fix all errors at once.

Ancient Dragon commented: Good suggestions. +26
mitrmkar 1,056 Posting Virtuoso
class coord
{
private:
	int xx;
	int yy;
public:
	int getxx(void);  
	int getyy(void);

Hmm, xx and yy are private member variables, whereas getxx() and getyy() are not. So you have to use these public getters that are there, so you ...

if(asteroid1.getxx( ) == asteroid2.getxx( ) && asteroid1.getyy( ) == asteroid2.getyy( ))
// ..

:)

Suicidal_tool commented: Fantastic Help..Thank you! +1
mitrmkar 1,056 Posting Virtuoso

Are these getxx and getyy member variables or perhaps functions? If the latter, then you need

if(asteroid1.getxx() == asteroid2.getxx() && asteroid1.getyy() == asteroid2.getyy())
	{
		cout<<endl;
		cout<<"Collision"<<endl;
	}

>> if i was to move this and just make a comparason function, could i send the object and its elements to another cpp?
*Clarify* passing the co-ordinates of both objects to a function, in the cpp with all my class details.

Most probably yes, as far as I understood the question.

mitrmkar 1,056 Posting Virtuoso

In Visual Studio, open

Project properties / Configuration properties / Linker / Input / Additional Dependencies

and add Advapi32.lib there.

mitrmkar 1,056 Posting Virtuoso

It's part of the windows.h library I think?

Yes it is, but you need to be sure that you link with Advapi32.lib.

mitrmkar 1,056 Posting Virtuoso

Use the extern keyword to introduce the variables inside the header (.h) files. Define these variables in their counterpart .cpp files.

For example, your header could be

#ifndef OBJECT_H_DEFINED
#define OBJECT_H_DEFINED

// file: object.h

// std::vector is needed in this header file
#include <vector>

// Introduce what is exposed by the 'var' namespace 
namespace var
{
    // You cannot have variables defined in a header file, which
    // is included by multiple .cpp files. So they need to be extern ...
    extern std::vector<game_object*> _objects_;
    extern std::vector<SDL_Surface*> _img_;
    extern std::vector<TTF_Font*> _font_;
    extern bool quit;
    extern bool pause;
    extern int sound_volume;
    // etc ...

    // An ordinary function declaration, no need for extern
    void ordinary_function();

    // A class declaration
    class some_class
    {
        // ctor
        some_class();
    };
}
#endif // ndef OBJECT_H_DEFINED

Then the .cpp file would be

// file: object.cpp

#include "object.h"
namespace var
{
    std::vector<game_object*> _objects_;
    std::vector<SDL_Surface*> _img_;
    std::vector<TTF_Font*> _font_;

    bool quit = 0;
    bool pause = 0;
    int sound_volume = 100;

    void ordinary_function()
    {
         // something here
    }

    // class definition ...
    some_class::some_class()
    {}
}

[EDIT]
The above is to demonstrate the basic idea of putting these things together, so given that there are e.g. SDL_Surface * and such, you also need the related headers for those included in proper places. But I hope that you get the basic idea though.

mitrmkar 1,056 Posting Virtuoso

>> I want to use gcount but I cant figure out the correct formatting.
Since you are having two string s there, you can get a string's length using e.g. .length() I.e.

string test = "abc";
// the following would print 3 
cout << test.length() << endl;

But then again, you don't need actually that, because you can check whether two strings are identical by

string test1 = "abc";
string test2 = "abc";

// a case sensitive comparison ...
if(test1 == test2)
{
    cout << "strings are identical" << endl;
}

// or ...
if(test1 != test2)
{
    cout << "strings are not identical" << endl;
}

Then last but not least, you probably want to handle the case where the files don't contain the same number of lines. As of now, your program would not detect that.

mitrmkar 1,056 Posting Virtuoso

I was not trying to trash anything.

I didn't mean to say/imply that you were intentionally trying to trash anything just to see what happens, you misunderstood me somewhat there.

>> 1. What is wrong with leaving the size of a2 undefined
You must be in full control of the memory you allocate at all times, i.e. you have to know the size of a given block of memory you've allocated and keep track of it (what do you think was the size of the block allocated for a2??). Otherwise you'll end up writing to memory, which may be reserved/used for something else. In this case it was and produced the nasty side-effects. The pointers don't automatically adjust the size of the memory block pointed to.

>> How could this have affected output streams in an apparently unrelated function?
Again, you simply trashed the memory ( pointer2[i] = pointer1[i] )

>> 2.And what is the proper way of copying structs?
One way is to allocate enough memory and do a memberwise copy. Also you might be interested in checking out overloading the assignment operator (=), which would be more suitable for non-POD types (Plain Old Data).

mitrmkar 1,056 Posting Virtuoso

The fix is simple,

// a1 comes with 10 elements ->
// a2 also comes with 10 elements (at minimum)
a2=new abc[ 10 ];

So, you were simply trashing memory. What was the main idea of doing the a2 allocation like you did? Were you just trying out C++ 'things'?

mitrmkar 1,056 Posting Virtuoso

where can I get a list of these WINAPI macros and their meaning?

Oh c'mon, haven't you tried Windows Data Types??

Depending on which IDE you have, you might be able to quickly locate these things by placing the cursor on a given typedef/define and do a "go to declaration/definition" from the IDE's context menu. Check whether your IDE supports that, however you may find the all the #ifdef/#else blocks in the headers a bit confusing.

mitrmkar 1,056 Posting Virtuoso

>>what is ULONG equivalent of C++ or it is just ULONG?
It is typedefed via <windows.h>, and is documented in Windows Data Types
That's a good page to lookup the data types and #defines used by Windows.

>>GetLastError()); //So GetLastError retuns a sring or char*?
No, see GetLastError Function. In general, the Windows API functions are documented in MSDN, so you can use MSDN as your primary reference.

>> //what does g_szDrvMsg do and what is TCHAR type?
Debug the while() loop there step by step so you'll understand how the thing works ;)

mitrmkar 1,056 Posting Virtuoso

There is a very basic problem that you have in main(). Now if you go through it carefully, you'll notice that there are float Mean and float MeanValue trying to serve the same purpose.

mitrmkar 1,056 Posting Virtuoso

I've changed LoadLibrary((LPCTSTR)("test.dll")) to LoadLibrary((LPCTSTR)("C:/Users/Nicholas Roge/Desktop/test/test.dll")), however there isn't any luck. Unless I misunderstood what you were telling me to try, however.

Have you UNICODE defined?
If so, then the following cast

LoadLibrary((LPCTSTR)("test.dll"))

causes this behaviour. The end result is that a non-UNICODE string gets passed to LoadLibraryW() and that will not work.

To fix it, change it to

LoadLibrary((LPCTSTR)_T("test.dll"));

You need to also #include <tchar.h>

mitrmkar 1,056 Posting Virtuoso

Unless I'm missing something line 12 sets the value of sz to 1 Gig. All that line does is initialize str to the first sz bytes of memblock.

The OP is trying to get a brand new std::string in;

std::string str(memblock, sz);

containing a copy of the data that was read in, so that would double the size of the allocated memory.

mitrmkar 1,056 Posting Virtuoso

A few quick notices,

1) These two are declared and used, but not implemented
bool operator==(const matrix &);
bool operator!=(const matrix &);
The code should not actually compile because of that, isn't your compiler saying anything?

2) There is no copy constructor i.e. matrix(const matrix &) , you absolutely need one, because of ( matrix (*this) ) . Now you are using the compiler-generated copy constructor, which causes you to delete memory twice in the destructor.

3) avoiding self-assignment
Now you have

if (!(*this==in))

however, that checks for equality, not self-assignment. One way to do that is

if (this == &in)
    return *this;

For some more advice, see C++ FAQ

4) There is an extra semicolon; if ((row!=in.getRows())||(column!=in.getColumns())); Once you get those things in order, you might post back with the revised code.

In general, yet a couple of major things to think of:
- managing throw/catch()
- resizing of a matrix wrt. memory corruption/leaks

mitrmkar 1,056 Posting Virtuoso

>>Since you are trying to allocate rather huge amounts of memory (2GB),

Nope. Its only 1 Gig which is less than what st::string.max_size() returns.

Actually the OP tries to get ~2 GBs .. I think you missed ...

std::string str(memblock, sz); //too much for visio :(
mitrmkar 1,056 Posting Virtuoso

error C3379: 'Form1::Form2:: DoubleBufferPanel' : a nested class cannot have an assembly access specifier as part of its declaration

Move the DoubleBufferPanel class outside your Form class i.e.

#pragma once

namespace Form1 { // <- You might have another namespace here
 // the usual 'using ...' stuff follows
 using namespace System;
 // etc ...
 // Next your new class ...
 public ref class DoubleBufferPanel : public Panel
  {
  public:
    DoubleBufferPanel(void)
    {
        this->SetStyle(ControlStyles::DoubleBuffer
         | ControlStyles::UserPaint
         | ControlStyles::AllPaintingInWmPaint,
          true);

        this->SetStyle(ControlStyles::DoubleBuffer, true);
        this->UpdateStyles();
    }
  };
 // Followed by the original code ...
 public ref class Form1 : public System::Windows::Forms::Form
 ...
mitrmkar 1,056 Posting Virtuoso

This should do ..

public ref class DoubleBufferPanel : public Panel
  {
  public:
    DoubleBufferPanel(void)
    {
        this->SetStyle(ControlStyles::DoubleBuffer
         | ControlStyles::UserPaint
         | ControlStyles::AllPaintingInWmPaint,
          true);

        this->SetStyle(ControlStyles::DoubleBuffer, true);
        this->UpdateStyles();
    }
  };
mitrmkar 1,056 Posting Virtuoso

I appear to have hit a memory limit in visual studio.

Since you are trying to allocate rather huge amounts of memory (2GB), I'd guess that the limitations are more probably imposed by your operating system (which one is it?) than the std::string implementation.

See MSDN documentation on Memory and Address Space Limits. Are you perhaps reaching the 2GB user-mode virtual address space limit there?

PS. As already suggested, perhaps process the file in much much smaller chunks than what you are now planning.

mitrmkar 1,056 Posting Virtuoso

Aren't you doing something illegal at line 25 ?

mitrmkar 1,056 Posting Virtuoso

i am not able to figure out when i write definition for my increment operator ++.....how it would change car[bashed]???

Sorry but I don't get what you are saying. Could you describe it in more detail?

mitrmkar 1,056 Posting Virtuoso

You have to move the int Banger::objectCount=0; to the the banger.cpp file.

mitrmkar 1,056 Posting Virtuoso

But my my application is a Win32 application, it shouldn't matter, no?

By reading your first post I got the impression that you are having 64-bit libraries etc and trying to get them working with VC Express, that would not work. Perhaps I understood it all wrong?

mitrmkar 1,056 Posting Virtuoso

I've added the .lib and header files under Project->Linker Dependencies and Project and Solutions->VC++ Directories (where I added library files for x64 and header files) but still nothing.

As far as I know Visual Studio 2008 Express Edition does not support 64-bit programs. However, by installing the correct Windows SDK you'll get the 64-bit tools enabiling you to compile/link from the command line. And possibly with extra tweaking you even can get the tools to integrate with the IDE.

Anyhow, you might want to ask these kind of questions on a Microsoft's dedicated Visual C++ Express Edition forum.

Note though that you may end up doing a whole lot of installing/uninstalling and reading of the various Readme files to get the things working.

mitrmkar 1,056 Posting Virtuoso

Is there a way to convert a String variable to char []?

I pretty much missed the fact that this is about Borland's String class.
In that case the looping over the string and copying it byte by byte using the [] operator won't work.

If you want to stick with char fileName[100] then you can use e.g. strcpy()/strncpy() together with the String's c_str() method.

However, wouldn't it be easiest to change the type of fileName to String , so you could do a simple assignment, instead of hassling with C-style strings.

PS. The order of the posts in this thread is odd ... let's see where this one lands.

mitrmkar 1,056 Posting Virtuoso

char fileName[100] = "unsaved.txt"

OK, what you have there seems like the right way of doing it, as long as newFileName.Length() does not exceed the buffer size. Just a suggestion, to simplify the code a little bit;

// also fileName is of type String ...
String fileName = "unsaved.txt";

// and ...
String newFileName = fileNameEdit->Text + ".txt";
rename( "unsaved.txt", newFileName.c_str() );
fileName = newFileName;

Regarding the crash (what kind of crash actually?), have you run the program in the debugger to see at which line it crashes?


[EDIT] Hmm, the post I'm replying to appears below this one.

mitrmkar 1,056 Posting Virtuoso

How is the fileName actually declared?

mitrmkar 1,056 Posting Virtuoso

however the cin doesn't seem to be working - I'm getting the initialised value of 0 for n no matter what I enter.

That's because you are passing n by value. You need to pass it by reference instead, i.e.

double gauss(fun f, double a, double b, int & n)
{
    cout << "\n********** GAUSS QUADRATURE **********"<< endl;
    cout << "For the equation f(t) = t^2" << endl;
    cout << "Enter the quadrature order, n you wish to use: " << endl;
    cin >> n;
    cout << "Enter the interval of integration, [a,b]: " << endl;
    cin >> a >> b;
}
mitrmkar 1,056 Posting Virtuoso

what I have done wrong?

To point out basic errors, see the comments below

#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>

using namespace std;

class tabledata {
    private:
        long double abscisass[28];
        long double weights[28];
    public:
        void set_values();
}  

// a global variable here, will you be using it? If not, delete it.
table;   

void tabledata::set_values () {

    // Both arrays are of size 28 -> the last index
    // you are allowed to use is 27, NOT 28

    abscisass[28] = 0.9739065285171717200779640;
    weights[28] = 0.0666713443086881375935688;
}

int main()
{
    // Here you have two uninitialized arrays
    long double abscisass[28], weights[28];

    // The variable name 'table' clashes with the one
    // you already have as a global variable, 
    // do something about it.
    tabledata table;
    table.set_values();

    // Here you illegally (again out-of-bounds) access the 
    // still-uninitialized 'weights' array local to this function.
    // Shouldn't you be using the 'table' instead?
    cout << "the answer is " << setprecision(25) << weights[28];

    return 0;
}
mitrmkar 1,056 Posting Virtuoso

NOTE:

ب
=
0x0628
= 
"\u0628"

0x0628 is not UTF-8, but rather UTF-16. Dave Sinkula's 0xD8 0xA8 is the UTF-8 representation of \u0628.

mitrmkar 1,056 Posting Virtuoso

Thanks Dave, I tried -pedantic option and it is still only giving a warning to me. Shouldn't it be a nice and proper error?

Maybe try -pedantic-errors

mitrmkar 1,056 Posting Virtuoso

thank you very much your reply and for your solution i was trying to do it completely differently
here is the code

// read the file from comand line and displys it
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

main(int argc, char *argv[])
{
  int fd ,numseats, i=0, ans, bufs=50;
  FILE* lp;
  char  ile[bufs];
  fd = open(argv[1],O_RDWR);
  
  if(fd <0)
    {
      printf("file s% not found",argv[1]);
      exit(1);
    }
  printf("would you like the output be send to file??1/2  :");
  
 
  if(scanf("%d",&ans) == 1)
    {
      printf("please specifie the file\n");
      scanf("%s",ile);
      lp=fopen(ile, O_RDWR); 
  
      while(read(fd, &numseats, sizeof(int)) > 0)
	fprintf(lp,"flight%4d: %4d seats available\n", i++, numseats);
    }
  else
    {

  while(read(fd, &numseats, sizeof(int)) > 0)
    printf("flight%4d: %4d seats available\n", i++, numseats);
    }
  /* finished */
  exit(0);
}

this code does compile but it gives me segmentation fault

Doesn't your compiler produce any warnings? Which compiler are you using?

mitrmkar 1,056 Posting Virtuoso

I'm suspecting that you are unnecessarily trying to convert data back and forth (being somewhat unfamiliar with c++). So, if you'd describe in detail what you need to do, someone here might suggest a simple solution.

mitrmkar 1,056 Posting Virtuoso

That sounds like something rather complicated. One thing I can say though is that if you are using WM_SETFOCUS/SetFocus() within that dialog box, then just don't. Those are not meant to be used with dialog boxes.
Rather use CDialog::GotoDlgCtrl() or WM_NEXTDLGCTL to set the focus.

mitrmkar 1,056 Posting Virtuoso

... so I don't have CPropertySheet::OnInitDialog()..

You could very easily arrange so that you'd have a class derived from CPropertySheet, in which case the above code snippet would do the job. I think that would be the 'most natural' way of doing what you are trying to accomplish.

I only have CPropertyPage::OnInitDialog()..

In that case you might try the following

// WM_INITDIALOG handler for your CPropSettingCriteria 
// property page class
BOOL CPropSettingCriteria::OnInitDialog() 
{
    BOOL bResult = CPropertyPage::OnInitDialog();

    // Try to get a pointer to the propertysheet
    CWnd * pParent = GetParent();

    if(pParent && IsWindow(pParent->m_hWnd))
    {
        pParent->GetDlgItem(IDCANCEL)->ShowWindow(FALSE);
        pParent->GetDlgItem(IDOK)->EnableWindow(FALSE);
    }

    return bResult;
}
mitrmkar 1,056 Posting Virtuoso

Have you tried the following ?

// WM_INITDIALOG handler of your property sheet class
// (derived from CPropertySheet)
BOOL CMyPropertySheet::OnInitDialog() 
{
    BOOL bResult = CPropertySheet::OnInitDialog();

    // Hide the Cancel button
    GetDlgItem(IDCANCEL)->ShowWindow(FALSE);

    // Disable the OK button
    GetDlgItem(IDOK)->EnableWindow(FALSE);

    return bResult;
}
mitrmkar 1,056 Posting Virtuoso

I beg to differ, in my copy of the ansi C spec section 2.2.4.2 - Numerical limits:

<snip>

am I reading it backwards and it means something else?

I think you are not understanding the following

Sizes of integral types

The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.

mitrmkar 1,056 Posting Virtuoso

If you need to resolve the path and file name of a .lnk file (i.e. a shortcut) that's dropped on the Audacity project, you'll need to use the IShellLink interface. Read about Shell Links in MSDN.

This is (fairly) new behaviour to Windows (might be in Vista) and I have searched for an example which I could understand with no luck!

Sorry but I don't quite understand what you are saying here, shell links have been around since Windows 95 / NT 4.0. I suppose Windows 7 hasn't brought anything new to shell links.

mitrmkar 1,056 Posting Virtuoso

There is an initialization failure ...

for( i = 0; i < n; i++ ) numberlist[i] == rand() % n ;
mitrmkar 1,056 Posting Virtuoso

I think the two friend declarations need template <class T>

template <class T>
class Tree
{
...
template <class T> friend void buildExprTree(Tree<T> & expr);
template <class T> friend int eval(Tree<T> & expr);
...
};
mitrmkar 1,056 Posting Virtuoso

"cannot convert from const Node *const to Node* Conversion loses qualifiers". I'm not sure how to fix this.

You can use const_cast, i.e.

Node * temp = const_cast<Node*>(this);

Maybe you could revise the 'constness' of the code (I did not look too closely). Perhaps read about Const correctness.

mitrmkar 1,056 Posting Virtuoso

yes. it's just a cpp file (probably could be .h) that holds some enums. no actual code in it or includes

There is a contradiction, in your first post you say that "Each file has: #include "include.h"". If enum.cpp actually includes include.h, that results in the error you described.

[EDIT]
Assuming "Each file" refers to source files ...
[/EDIT]

mitrmkar 1,056 Posting Virtuoso
+		rgbb	0x0044714c "øÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÿÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍþÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"	unsigned char [3]

And when Im writing to a new file, it writes just the bits, and put all this junk just after it??...Am Im imagining too much?

Now remember the second parameter to write() , that specifies how many bytes are written.

PS. Maybe you could try to re-post your code

mitrmkar 1,056 Posting Virtuoso

using this :

writer.write(reinterpret_cast<char*>(&img_pix[i].rgb) ,sizeof(img_pix[i].rgb));

the file gets 10,7 MB o__o"
using this :

writer.write(reinterpret_cast<char*>(&img_pix[i].rgb[0]) ,sizeof(img_pix[i].rgb[0]));

the file gets 3,4 MB ..
using this:

writer.write(&img_pix[i].rgbb[0],sizeof(img_pix[i].rgbb[0]));

the file gets 914KB
using this:

writer.write(reinterpret_cast<char*>(&img_pix[i].rgbb) ,sizeof(img_pix[i].rgbb));

the file gets 2,67 MB
using this:

writer.write(reinterpret_cast<char*>(&img_pix[i].rgbb[0]) ,sizeof(img_pix[i].rgbb[0]));

the file gets 914 KB

It seems that you are desperately trying various ways to write the file.

Maybe relax and try to master e.g. a binary .pnm file of a very small size, say 2x2 pixels hence being easily viewed in any hexeditor at a glance (notepad and wordpad surely are poor choices for checking the files' content).

Try for example the following struct for reading/writing

struct Pixel
{
    // 3 bytes represents a single pixel
    unsigned char rgb[3];
};

Then when you read in the file you might

// ... code here to read in the file's header ...

// allocate enough memory to read in rest of the file
const int pixels = width * height;
Pixel * p = new Pixel[pixels];

for(int ii = 0; ii < pixels; ++ii)
{
    // read 3 bytes at a time
    if( ! file.read(reinterpret_cast<char *>(p[ii].rgb), 3))
    {
        // should not happen, handle error ...
        break;
    }
}

// all done

Then to write the file, you can iterate over the array issuing file.write(reinterpret_cast<const char *>(p[ii].rgb), 3) Remember that the second parameter to both read() and write() determines how many bytes each I/O operation involves.

mitrmkar 1,056 Posting Virtuoso
mitrmkar 1,056 Posting Virtuoso

The function prototype for ON_MESSAGE() is afx_msg LRESULT memberFxn( WPARAM, LPARAM ); Ctry_ENTERDlg::OnBnClickedButton1 does not match, so you might add a new member function which handles the message.

See User-Defined Handlers

mitrmkar 1,056 Posting Virtuoso

If I use the uncommented 3 lines for getting an int out of a stringstream, the value in MPV is wrong. However, if I make a new stringstream, then it works fine. I thought setting .str("") was essentially resetting the stringstream?

If the stream object is in error state, then you also need to call clear() in order to make the object functional again. Could that be the reason in this case?

mitrmkar 1,056 Posting Virtuoso

I'm dealing with a map of vectors, and I'm making sure I clean up all the memory used. So, what exactly is the best way to handle this?

As soon as the map goes out of scope, its destructor takes care of destructing all the vectors, whose destructors in turn destruct all the strings. So it all happens automagically (as long as you are not storing pointers to objects)