c++

Custom ComboBox for SearchBox

Hi, I'm implementing a custom combobox to behave like a searchbox. It is constructed from an Edit control, a Button and a Listbox. I'm trying to open the listbox on mouse click on the button, it seemed to be simple but become complicated. First I tried to manage the mouse click on the "BN_CLICKED", but then I discovered it's too late a...

what is invalidate,update methods do in VC++

Hi all, i have small doubt regarding the window functions in c++. what exactly "invalidate()" function do? what message does it sends?when we need to call this? also what is "update()" function? is "invalidaterect()" works similar to "invalidate()" function?. Thanks ...

C# shared memory between C++ application and C# application using COM object

Hi Guys, Is it OK/possible to have a shared memory in a COM object which will be consumed by applications built using C# and/or C++? Can C# access shared memory in COM object without crash? Thanks, Adi Barda ...

A little problem in handling 2-D arrays with class

class linklist4x4 { private: struct node4x4 { double data[4][4]; node4x4 *link; }*p; public: linklist4x4(); void append( double* num ); void add_as_first( double* num ); void addafter( int c, double* num ); //void del( double* num ); void display(); int count(); double*...

Is creating a base class for all applications of a particular type good design?

I am trying to write a graphics application in C++. It currently uses OGRE for display, but I'd like it to work with Irrlicht or any other engine, even a custom rendering engine which supports my needs. This is a rather long question, so I'd appreciate help on re-tagging/ cleanup (if necessary). I'll start with a little background. ...

Detect removable drive (e.g. USB flash drive) C/C++

How can I detect when a removable disk drive is (dis)connected to the system? How to get the mount path (for Linux) and the drive letter (for windows)? EDIT: Is there a way to detect the currently connected devices? ...

Getting input from user using cin

I am using Turbo C++ 3.0 Compiler While using the following code .. char *Name; cin >> Name; cout << Name; When I gave input with space ... its only saving characters typed before space .. like if I gave input "QWERT YUIOP" ... Name will contain "QWERT"; Any explaination why ?? ...

Prevent class inheritance in C++

Recently one of my friend asked me how to prevent class inheritance in C++. He wanted the compilation to fail. I was thinking about it and found 3 answers. Not sure which is the best one. 1) Private Constructor(s) class CBase { public: static CBase* CreateInstance() { CBase* b1 = new CBase(); return b1; } private: CBase(...

Modifying items of boost multi index container

struct tagEnumdef{}; struct tagName{}; struct tagWidget{}; template< class type > class ParamTags; template<> class ParamTags<int> { public: typedef tagEnumdef tag; }; template<> class ParamTags<QString> { public: typedef tagName tag; }; template<> class ParamTags<QWidget*>{ public: typedef tagWidget tag; }; typedef boost::multi...

Problem compiling simple C++ progam

Hi, I was provided this simple C++ [I think] program to investigate the maximum size of int that can be stored: #include <limits.h> #include <iostream> void main ( int argc , char * argv[]) { cout << "INT_MAX " << INT_MAX << endl ; cout << "INT_MAX +1 = " << INT_MAX + 1 << endl ; cout << "INT_MAX -1 = " << INT_MAX - 1 ...

static Member access linker problems

gph is a singleton class with no getInstance method class gph { public: static void newfun(); static void newfun1(); //...// private: gph(); }; This class gets build into a static library Now I have a Dll from where I need to access the static function . So class A is a part of a Dll I have a C++ member function say ...

Any Framework to build a code checking website(like SPOJ) ?

Hi guys, My col is planning to conduct a online coding competition.. Im now looking for a framework that checkes user's code and returns the appropriate result.. Only C,C++ support is enough.. -Dinesh ...

Making wide application (with plugins)

Hi guys, I'm going to make my application extensible. Where I can read information about writing programs which support plugins? C++ ...

How to generate a good random seed to pass to srand()?

Hi, I am writing a C++ program which needs to create a temporary file for its internal usage. I would like to allow concurrent executions of the program by running multiple proccesses, so the temporary file name needs to be randomized, that way each spawned process will generate a unique temporary file name for its own use. I am using r...

Run bash with redefined PS1 env variable

Hi, guys! I have written cpp aplication called MyShell that takes as the params some real shell name (generally bash) and its params. MyShell works as a wrapper for it. I need to change command prompting for the inner shell, specifically the PS1 environmental variable. I know how to do it command-line way using PS1 env var: $ PS1="[m...

Opaque object for template in another namespace...

Hi, I know how to do an opaque object in C++ as following: // my_class.hpp class opaque_object; class my_class { my_class(); ~my_class(); opaque_object *m_opaque_object; }; // my_class.cpp #include <my_class.hpp> class opaque_object { // ... }; my_class::my_class() { m_opaque_object = new opaque_object(); } my_class::~...

machine precision

Hi, I wonder if there is something like eps to represent the value of machine precision in C++? Can I use it as the smallest positive number that a double can represent? Is it possible to use 1.0/eps as the max positive number that a double can represent? Where can I find eps in both C++ and C standard libraries? Thanks and regards! ...

Does C++ support constant arrays of type string?

Hi, I'm a programming student in my first C++ class, and for a recent project I did, I was unable to create an array of strings like I could do in C#: string MONTHS[ARRAY_CAPACITY] = { "Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec" }; // this yields many compiler errors in C++ Is it possible to...

use of char * vs std::string in different environments

I have been using std::string in my code. I was going to make a std::string and pass it by reference. However, someone suggested using a char * instead. Something about std::string is not reliable when porting code. Is that true? I have avoided using char * as I would need to do some memory management for it. Instead I find using the std...

How to guard against memory leaks?

I was recently interviewing for a C++ position, and I was asked how I guard against creating memory leaks. I know I didn't give a satisfactory answer to that question, so I'm throwing it to you guys. What are the best ways to guard against memory leaks? Thanks! ...