i'm new to C++ as well as for windows programming..
i have created a window using msdn CreateWindow() function
which works correctly..now i would like to create a child window...the parent window should control the child window...
Any helps sample code regarding this .
Thanks in advance
...
When a compiler finds a signed / unsigned mismatch, what action does it take? Is the signed number cast to an unsigned or vice versa? and why?
...
Here is a complete example.
I want to forbid using A::set from objects casted from B to A by allowing only casting
B to const A.
How to do it?
(I can't use virtual functions)
#include <iostream>
#include <cassert>
using namespace std;
class A {
public:
int get() const { return i_; }
void set(int i) { i_ = i; }
protected:
int ...
We have a class whose semantic behaviour is like the following :-
struct Sample
{
~Sample() throw()
{
throw 0;
}
};
void f ()
{
try
{
delete new Sample;
}
catch (...){
}
}
I know that throwing exceptions in dtors is evil; but the relinquishment of a 3rd Party library resource is throwing an exception (but can...
At the Boost library conference today, Andrei Alexandrescu author of the book Modern C++ Design and the Loki C++ library, spoke about why iterators are bad, and he had a better solution.
I tried to read the presentation slides, but could not get much out of them. I have these questions for the StackOverflow community:
Are iterators ba...
I've recently been wrestling with an algorithm which was badly implemented (i.e. the developer was pulled off onto another project and failed to adequately document what he'd done) in C#.
I've found an alternative (from numerical recipes) which works but is written in C++. So I'm thinking probably the safest way to get something workin...
// edited by Neil Butterworth to conserve vertical space
#include <stdio.h>
struct A;
struct B;
A& GetAInstance();
B& GetBInstance();
struct A {
A() {
printf( "A\n" );
}
~A() {
printf( "~A\n" );
B& b = GetBInstance();
}
};
struct B {
B() {
printf( "B\n" );
}
~B() {
...
I know, that for C++ and Java it is a well established naming convention, that constants should be written all uppercase, with underscores to separate words. Like this (Java-example):
public final static Color BACKGROUND_COLOR = Color.WHITE;
public final static Color TEXT_COLOR = Color.BLACK;
This naming convention is easy to understa...
I have a CMFCToolBar-derived class and an insance thereof is the member of a CDockablePane-derived class.
I looked at the VisualStudioDemo sample to see how it's done and have this so far:
int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
// Removed all "return -1 on error" code for better readability
CDockablePane::OnCre...
int somefunction(bool a)
{
try
{
if(a)
throw Error("msg");
return 2;
}
catch (Error const & error)
{
//do i need to return anything here??
//return -1;
}
}
...
As I try to modernize my C++ skills, I keep encountering this situation where "the STL way" isn't obvious to me.
I have an object that wants to gather contributions from multiple sources into a container (typically a std::vector). Each source is an object, and each of those objects provides a method get_contributions() that returns any...
This is one of my most dreaded C/C++ compiler errors:
file.cpp(3124) : fatal error C1004: unexpected end-of-file found
file.cpp includes almost a hundred header files, which in turn include other header files. It's over 3000 lines. The code should be modularized and structured, the source files smaller. We should refactor it. As a ...
I am writing Windows application (with Borland C++ Builder), which stores large number of text files. I want users to be able to search these files very fast, so I need an indexing and search library. I do not use database, but my own file format for storing the documents (all are in a single file).
Are there such libraries for Windows?...
I'm using fstream is there any way to get the failure message/ excpetion. for example if unable to open the file I want to get the reason for it.
...
We've always been an Intel shop. All the developers use Intel machines, recommended platform for end users is Intel, and if end users want to run on AMD it's their lookout. Maybe the test department had an AMD machine somewhere to check we didn't ship anything completely broken, but that was about it.
Up until a few of years ago we ju...
I'm subclassing QProgressBar in a custom widget, and I overwrote the paintEvent method with the following code :
void myProg::paintEvent(QPaintEvent *pe)
{
QProgressBar::paintEvent(pe);
QRect region = pe->rect();
QPainter *painter = new QPainter(this);
QPen *pen = new QPen;
painter->begin(this);
painter->setBrus...
When using the MFC class CDatabase to connect to a data source, is there any way to execute SQL statements without having to open a CRecordSet object? I ask because CRecordSet::Open() appears to throw an exception when I use it to call stored procedures that don't return anything - and there's no reason to expect results from, say, sp_d...
I'm creating a C api that hides some functionality in a DLL file.
Since everything is C++ on the inside most of the functions works against handles which maps directly to this pointers on the inside of the API.
To get a some degree of type safety for those handles I define them like this:
typedef struct MyType1* MyType1Handle;
typedef...
How can I deny access to a file I open with fstream? I want to unable access to the file while I'm reading/writing to it with fstream?
...
I have a class TContainer that is an aggregate of several stl collections pointers to TItems class.
I need to create an Iterator to traverse the elements in all the collections in my TContainer class abstracting the client of the inner workings.
What would be a good way to do this?. Should I crate a class that extends an iterator (if ...