c++

What aspect oriented language is a good place to start for a c++ programmer

The only one I know of is called "e" which is used for test bench design in hardware design and verification but I want something for general purpose programming. ...

Specialize member function template of a class template

I have the following code: #include <stdio.h> template<int A> class Thing { // 5 public: Thing() : data(A) { } template<int B> Thing &operator=(const Thing<B> &other) { printf("operator=: A = %d; B = %d\n", A, B); printf("this->data = %d\n", data); } ...

C++ interacting with a dynamic webpage?

I was thinking recently about what projects I could start that would be of use to me and this came up. I post on various forums a daily updated journal entry that is the same for each forum. I also keep a log of the journal entries as individual docx files on my hard drive. I figured it would be great if I could create a program that ...

C++ Puzzle: Prevent heap allocation for derived classes, allow automatic and static

Objectives: Objects of class Base may be static, automatic, allocated directly on the heap, and take part in composite objects allocated anywhere For any class Derived which has Base as an accessible ancestor, objects may be static or automatic and take part in composites, but may not be allocated directly on the heap Example: #inc...

Non-type template parameter... that's a template! (C++)

I'm basically looking to generate a wrapper for a generic C function without having to manually specify the types. So I have a callback with a fixed prototype but I'm going to need to do some special code in the wrapper based on the type of the wrapped function... So basically I'm thinking about using a static method in a class template ...

Are there any scenarios in which multiple inheritence is necessary?

Are there any scenarios in which multiple inheritence is necessary? Please provide examples. ...

array of integers vs. pointer to integer in c++

If I have int x[10] and int *y, how can I tell the difference between the two? I have two ideas: sizeof() is different. &x has different type --- int (*p)[10] = &x works but not int **q = &x. Any others? In some template library code, I need to determine whether a pointer is a "real" pointer or degenerated from an array...

App started by logged off XP user can seen on desktop of a different user

This is a coding question. Please read it before you flag it as belonging on ServerFault as the last one I wrote got thrown over there in less than 5 minutes. I'm testing my win32/c++ application on XP which has the latest service packs. It contains two administrative user accounts both without passwords. I log in as User1 and start my ...

Problems implementing a quicksort

Got it working, final code: Pushes back data and sorts both in synchronization #include "std_lib_facilities.h" struct Name_pairs { vector<string>names; vector<double>ages; void quicksort(vector<string>& num, vector<double>& num2, int top, int bottom); int divide(vector<string>& array, vector<double>& array2,...

#import'ing msado15.dll, is there another way?

In all ADO C++ code I can find, there is a line #import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile") I understand that this line "incorporate information from a type library", and that "The content of the type library is converted into C++ classes". What? I'm also looking for the he...

One MinGW, many GCC versions - how to do it?

Is it possible to have different GCC installations working with one MinGW installation? By MinGW I mean the common base which is always needed regardless which version of GCC compiler we're going to install and use; MinGW runtime binutils make MinGW API for MS-Windows and many other components which are part of MinGW but are not ...

Qt and C++ - troubles with signal/slots

Hi guys. I have a small trouble with signal/slot in Qt. I have an class wich has public slot: void doSomething(); In constructor of this class i do: this->connect( ui->textFrom, SIGNAL(returnPressed()), this, SLOT(doSomething()) ); I have QLineEdit - textFrom object. ../moc_mainwindow.cpp:66: undefined reference to...

Things to keep in mind when migrating from VS2008 to VS2010.

So, I'll be soon working on porting two APIs (C++ and C++/CLI) to use the VS2010 compiler. I think it'd be a good idea to have a head start on this. Any tips? ...

how does ofstream or ostream type cast all types to string?

any system defined user type past to ostream object is converted to a string or char* ? like cout<<4<<"Hello World"; works perfectly fine, how is this achieved? is the << operator overloaded for each and every type? is there a way to achieve it through just one generic overloaded function? what i mean is can i have just one overloaded...

How can/should C++ static member variable and function be hidden?

m_MAX and ask() are used by run() but should otherwise not be public. How can/should this be done? #include <vector> class Q { public: static int const m_MAX=17; int ask(){return 4;} }; class UI { private: std::vector<Q*> m_list; public: void add(Q* a_q){m_list.push_back(a_q);} int run(){return Q::m_MAX==m_list[0]->a...

Why would a virtual function be private?

I just spotted this in some code: class Foo { [...] private: virtual void Bar() = 0; [...] } Does this have any purpose? (I am trying to port some code from VS to G++, and this caught my attention) ...

real use cases of casting operators

I want to know more about the casting (like static cast, dynamic cast, const cast and reinterpret cast) and when do we REALLY need that (real life scenario)? Any references/links/books will be appreciated. Thanks. ...

Is there a way to preserve the BITMAPFILEHEADER when loading a Bitmap as a Windows resource?

I've been working on testing a few things out using SFML 1.4 (Simple and Fast Multimedia Library) with C++ and Visual C++ 2008 Express Edition. To avoid having external images with my graphical programs, I was testing out the sf::Image::LoadFromMemory(const char * Data, std::size_t SizeInBytes) function with Bitmap resources loaded usin...

Pedantic gcc warning: type qualifiers on function return type

When I compiled my C++ code with GCC 4.3 for the first time, (after having compiled it successfully with no warnings on 4.1, 4.0, 3.4 with the -Wall -Wextra options) I suddenly got a bunch of errors of the form warning: type qualifiers ignored on function return type. Consider temp.cpp: class Something { public: const int getConstT...

pointers as template parameters?

I have a container class, we'll call it template <class T> CVector { ... } I want to do something different with this class when T is a pointer type, e.g. something along the lines of: template <class T*> CVector< SomeWrapperClass<T> >; where SomeWrapperClass is expecting the type of the pointed to thing as its parameter. Unfort...