In C++, a function template specialization is supposed to act exactly like a normal function. Does that mean that I can make one virtual? For example:
struct A
{
template <class T> void f();
template <> virtual void f<int>() {}
};
struct B : A
{
template <class T> void f();
template <> virtual void f<int>() {}
};
int m...
Hi, I'm trying to get a simple mixture between Managed C++ and plain C++ working. I'm using Visual Studio 2005 but keep hitting a problem. Here's my setup.
First, I have a simple DLL built from the code
#using "mscorlib.dll"
#include "windows.h"
__declspec(dllexport)
void sayHello()
{
OutputDebugStringA( "Hello from managed code!...
In Visual Studio, there's the compile flags /MD and /MT which let you choose which kind of C runtime library you want.
I understand the difference in implementation, but I'm still not sure which one to use. What are the pros/cons?
One advantage to /MD that I've heard, is that this allows someone to update the runtime, (like maybe patch...
I ran into a compiler error that didn't make much sense to me:
#include <memory>
using namespace std;
auto_ptr<Table> table = db->query("select * from t");
error: conversion from 'Table*' to non-scalar type 'std::auto_ptr< Table>' requested
However, the following line does work:
auto_ptr<Table> table(db->query("select * from t"));
...
I"m working on a C++ Win32 application for which I'm trying to essentially "auto detect" if a device has been plugged into one of the RS232 ports and then if it has been disconnected.
The checking for a connected device is easy enough because my use case allows me to assume that this particular thread will be the first to try to initiat...
I have a DVD cataloging application that I wrote a few years ago with MFC. Records are saved in a sqlite database, so basically it's a CRUD app. UI-wise, it has a tree view on the left, a list view (grid) on the top right, and an HTML view (embedded IE) on the bottom right. Nothing fancy.
I wanted to update the app with more features, b...
I'm recording some statistics in my application. One of the statistics is the size of BigDataStructure. I have two options:
Create a counter and increment /
decrement the counter each time
there is an add/remove from the
BigDataStructure.
Each time there is an add/remove
from the BigDataStructure, set the
counter to BigDataStructure....
I'm working in Quartz/Core-graphics. I'm trying to create a black and white, 1b per pixel graphics context.
I currently have a CGImageRef with a grayscale image (which is really black and white). I want to draw it into a black and white BitmapContext so I can get the bitmap out and compress it with CCITT-group 4. (For some reason Quart...
Alright here's the deal, I'm taking an intro to c++ class at my university and am having trouble figuring out how to change the extension of a file. First, what we are suppose to do is read in a .txt file and count words, sentences, vowels etc. Well I got this but the next step is what's troubling me. We are then suppose to create a new ...
Question:
How to display the value of a C++ iterator using WinDbg, illustrated below:
for (vector<string>::iterator i = args.begin(); i != args.end(); i++)
//omitted
//for instance:
} else if (*i == "-i") {//attempting to display the value of *i
++i;
if (!::PathFileExistsA(i->c_str()))
{
Note:
Using ?? evaluate C++ expression ...
When I moved a program from a Mac to this Windows PC, the VC++ 2008 compiler is giving me errors for passing unsigned ints to the cmath pow() function. As I understand, this function is not overloaded to accept anything but floating-point numbers.
Is there some compiler flag/setting that will ignore these errors? Also does anyone know h...
I use wxWidgets to create test tools at work. I have always created the GUI by creating the widgets in code. I haven't tried any of the tools available that help to do this. How do other users of wxWidgets typically create their interface? If you use a tool, which tool do you use? If you use a tool, what advantages and disadvantages...
This may take a little explaining, so please bare with me.
I have a class "Class" which has a member std::list, I want to search that list/tree for an item, specifically an item with a specific name.
A basic representation of my class is as follows.
#include <list>
#include <string>
class Class {
std::string _name;
std::list<C...
I'm interested to know if it is possible to have some comments in a function (c, c++, java) in a way that doxygen could put them in the generated html file.
for example:
function(...)
{
do_1();
/**
* Call do_2 function for doing specific stuff.
*/
do_2();
}
...
I'm writing some code against a C++ API that takes vectors of vectors of vectors, and it's getting tedious to write code like the following all over the place:
vector<string> vs1;
vs1.push_back("x");
vs1.push_back("y");
...
vector<string> vs2;
...
vector<vector<string> > vvs1;
vvs1.push_back(vs1);
vvs1.push_back(vs2);
...
vector<vector<...
ATL CWindow class has a useful virtual method OnFinalMessage which is called after the last window message for the window is processed - at this point it is safe to destroy or deleted any objects associated with the window. Is there any equivalent for windows derived from the MFC CWnd class?
...
For instance:
0:000> ?? testFile //check this variable
char * 0x009c6758
"e:\TEST\example.FOO"
Question:
How can I check for a NULL-terminated character in above?
...
I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF.
I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem.
However, there doesn't...
When does using pointers in any language require someone to use more than one, let's say a triple pointer. When does it make sense to use a triple pointer instead of just using a regular pointer?
For example:
char * * *ptr;
instead of
char *ptr;
...
For reference I'm using the window superclass method outlined in this article. The specific issue occurs if I want to handle WM_NOTIFY messages (i.e. for custom drawing) from the base control in the superclass I either need to reflect them back from the parent window or set my own window as the parent (passed inside CREATESTRUCT for WM_(...