c++

Freeing memory allocated in a different dll

I have an exe using a dll which is using another dll. This situation has arisen: In dll1: class abc { static bool FindSubFolders(const std::string & sFolderToCheck, std::vector< std::string > & vecSubFoldersFound); } In dll2: void aFunction() { std::vector<std::string> folders; std::string...

C++, Accept lowercase and uppercase letters in a variable.

I want to allow the user to use lowercase or uppercase letters giving the value to the char type variable... Any help?? ...

A Good Way to Store C++ CLI Arguments? (W/O using libraries)

So, I'm writting a CLI application in C++ which will accept a bunch of arguments. The syntax is pretty typical, -tag arg1 arg2 -tag2 arg1 ... Right now, I take the char** argv and parse them into an std::map< std::string, std::list<**std::string** > > > The key is the tag, and the list holds each token behind that tag but before the...

fixing memory leaks when you're returning the leaked memory?

How do you fix a memory leak where you're returning from the function the leak itself? For example, I make a char* returnMe = new char[24324]; returnMe is what ends up getting returned from the function. How do you account for this memory leak? How do you destroy it once it's been returned? I have some memory management rules in plac...

Self Organizing Map (SOM) Implementation

I'm looking for a C, C++ or Java based SOM implementation with licensing applicable for commercial use (non-zero cost is okay). So far I'm aware that there exists SOM_PAK (from Kohonen), but the licensing forbids commercial use. Is anyone aware of alternative implementations? ...

Would C# benefit from distinctions between kinds of enumerators, like C++ iterators?

I have been thinking about the IEnumerator.Reset() method. I read in the MSDN documentation that it only there for COM interop. As a C++ programmer it looks to me like a IEnumerator which supports Reset is what I would call a forward iterator, while an IEnumerator which does not support Reset is really an input iterator. So part one of ...

Is it possible to wrap boost sockets with Pimpl?

Hi, in a project we want to wrap the Boost Asio socket in a way, that the using class or the wrapping .h does not have to include the boost headers. We usually use pointers and forward declarations for wrapped classes. Foward declaration: namespace boost { namespace asio { namespace ip { class udp; } } } And...

Can a class be declared static in c++?

Is this legal in c++ (yes i know it's legal in .net), and if so, how/why would it be used? static class foo{ public: foo(); int doIt(int a); }; ...

error when I call strcmp Invalid conversion from 'int' to 'const char*'

I'm using strcmp to compare character arrays in c++, but I get the following error for every occurrence of strcmp: error: invalid conversion from 'int' to 'const char*' followed by: error: initializing argument 2 of 'int strcmp(const char*, const char*)' I've include string, string.h, and stdio.h and here is my code, thanks to all who ...

wrong return value by mysql_num_fields in C++

thanks for u r reply please give your reply for below program. For table creation and insertion i am using these string. Create table mystudents(sname varchar(50),sno varchar(25),mark1 numeric,mark2 numeric); insert into mystudents values('lala','tk001',100,100); VC+++ CString("select * from mystudents;") int status = mysql_query(hn...

Cross platform programming question (file I/O)

I have a C++ class that looks a bit like this: class BinaryStream : private std::iostream { public: explicit BinaryStream(const std::string& file_name); bool read(); bool write(); private: Header m_hdr; std::vector<Row> m_rows; } This class reads and writes data in a binary form...

Set Visual Studio (conditional) breakpoint on local variable value

I'm trying to debug a method which among other things, adds items to a list which is local to the method. However, every so often the list size gets set to zero "midstream". I would like to set the debugger to break when the list size becomes zero, but I don't know how to, and would appreciate any pointers on how to do this. Thanks. ...

C++ STL:map search by iterator to another map

I'm trying to jump through some hoops to organize data in a special way. I'm including a simplified piece of code that demonstrates my pain. I can't use boost. I'm using the latest version of g++ in cygwin. #include <iostream> #include <map> using namespace std; int main () { map< int,int > genmap; map< int,int >::iterator g...

Using free inside the destructor of an object freed with delete

I'm having a little issue. I have an object that I'm freeing with delete, and it has a char* that's being freed with free in its destructor. The reason I'm using free is because I used strdup and malloc in creating the char pointers. The reason I'm using malloc is because I used strdup to begin with in most code paths. Would this scenari...

Ubuntu desktop development environment (GNU tools)

I am setting up a Linux development machine (Ubuntu 9.0.x). I want to know the best development environment for a C++ developer on Ubuntu - giving my background (see below). 5 years+ C++ 5 years Visual Studio Not much experience using GNU tools (GCC, GDB, make, etc.) 6 months or so of using Emacs at university (about 8 years ago!) - ...

C++ object and C style cast question

I have the following code compiled by gcc: #include <iostream> using namespace std; class Buffer { public: operator char *() { cout << "operator const * called" << endl; return buff; } private: char buff[1024]; }; int main(int, char**) { Buffer b; (char *)b; // Buffer::operator char * is called here return 0; } ...

Function/Method Overloading C++: Data type confusion?

Hi, I'm having some trouble overloading methods in C++. As an example of the problem, I have a class with a number of methods being overloaded, and each method having one parameter with a different data type. My question: is there a particular order in the class these methods should appear in, to make sure the correct method is called d...

How can including GDB debugging symbols 'break packages' ?

When I am building packages, (on Gentoo, but that's not too important to this question) I get this warning that '-ggdb3' flag can 'break packages. I have yet to find an instance of when that is true. Although I once found some code which broke under different optimisation settings, that's different from including debugging symbols. ...

debug vs. release dll size

Why in cpp a dll in debug mode is X10 bigger than release while in .Net they are almost the same size? ...

C++ optimization of reference-to-pointer argument

I'm wondering with functions like the following, whether to use a temporary variable (p): void parse_foo(const char*& p_in_out, foo& out) { const char* p = p_in_out; /* Parse, p gets incremented etc. */ p_in_out = p; } or can I just use the original argument and expect it to be optimized similarly to the...