I've been investigating "how should a modern windows c++ application register its file types" with Windows (see http://stackoverflow.com/questions/2828637/c-how-do-i-correctly-register-and-unregister-file-type-associations-for-our-ap).
And having combed through the various MSDN articles on the subject, the summary appears to be as follo...
When implementing a MessageFactory class to instatiate Message objects I used something like:
class MessageFactory
{
public:
static Message *create(int type)
{
switch(type) {
case PING_MSG:
return new PingMessage();
case PONG_MSG:
return new PongMessage();
....
}
}...
class B {
public:
static int a;
};
class C:B {
};
I want to use a variable through any inherited classes but it has problem when I declare a.
B::B() {
a=1;
};
Do I do it right ?
Thanks for reading and waiting for your comments.
// I miss semicolons which is not the error I'm talking .
// This is an error when I try to delcare...
I have a map where I'd like to perform a call on every data type object member function. I yet know how to do this on any sequence but, is it possible to do it on an associative container?
The closest answer I could find was this: Boost.Bind to access std::map elements in std::for_each. But I cannot use boost in my project so, is there ...
I'm creating a custom control class and since I want complete control of it, I register the class and want to use the class's
LRESULT CALLBACK OGLTOOLBAR::ToolProc(HWND, UINT, WPARAM, LPARAM)
but it's not letting me.
I'm doing:
HWND OGLTOOLBAR::create(HWND parent,HINSTANCE hInst, int *toolWidthPtr)
{
if (toolhWnd != NULL)
...
I have some managed code that calls to a method inside some native DLL(i have the appropriate symbol files).
Sometimes, that native method throws an exception which I catch in my managed code. However, when i print the stacktrace from my caught exception, I see only managed code (the last frame is the call to the native code .. but it do...
Hi. I'm working on my C++ assignment about soccer and I encountered a problem with map.
My problem that I encountered is that when I stored 2 or more "midfielders" as the key, even the cout data shows different, but when I do a multiplication on the 2nd ->second value, it "adds up" the first ->second value and multiply with it.
E.g.
J...
Possible Duplicate:
How do I iterate over cin line by line in C++?
I need to read all lines from a file:
std::ifstream file("...");
std::vector<std::string> svec(
(std::istream_iterator<std::string>(file)),
(std::istream_iterator<std::string>()),
);
but it is read as words.
...
Trying to debug some linker errors, I turned on /VERBOSE and I'm trying to make sense of the output. It occurs to me that I really don't know how to read it.
For example:
1>Compiling version info
1>Linking...
1>Starting pass 1
1>Processed /DEFAULTLIB:mfc80.lib
1>Processed /DEFAULTLIB:mfcs80.lib
1>Processed /DEFAULTLIB:msvcrt.lib
1>Proc...
I want to fill the template parameters passed to a variadic template into an array with fixed length. For that purpose I wrote the following helper function templates
template<typename ForwardIterator, typename T>
void fill(ForwardIterator i) { }
template<typename ForwardIterator, typename T, T head, T... tail>
void fill(ForwardIterato...
Hello all, i need to know how to use an IP address like inet_addr("192.168.0.2"); in C++
where this returns DWORD. My wrapper in C# treats this field as an Int?
Can anyone help on this misunderstanding?
...
Given the following piece of (pseudo-C++) code:
float x=100, a=0.1;
unsigned int height = 63, width = 63;
unsigned int hw=31;
for (int row=0; row < height; ++row)
{
for (int col=0; col < width; ++col)
{
float foo = x + col - hw + a * (col - hw);
cout << foo << " ";
}
cout << endl;
}
The values of foo ar...
Hi Guys,
a bit of a naive question, but nonetheless. I am trying to break up a for loop in which a 2d Matrix is being read. I would like to write a callback function to consume row-wise/col-wise chunks per row/col iteration. Any hints on how to tie up the callback function with iteration?
bool ReadMatrix(const int** array) {
........
Hello everyone!
I have some problems with implementing class which written in C++, because I not familiar with c++ .. if someone could help with implementing it in Objective C
#ifndef ENTITY_H
#define ENTITY_H
class BaseGameEntity
{
private:
int m_ID;
static int m_iNextValidID;
void SetID(int val);
public:
BaseGa...
I'm trying to develop software that is intelligent wrt sleep events (cleanly closing network connections, making sure data restart locations are set properly, etc).
Are there mechanisms in QT (4.6) currently that facilitate me responding to system power events?
...
I have a problem with stl priority queue.I want to have the priority queue in the increasing
order,which is decreasing by default.Is there any way to do this in priority queue.
And what is the complexity of building stl priority queue.If i use quick sort in an array which takes O(nlgn) is its complexity is similar to using priority que...
Silly question, but say you have class Foo:
class Foo
{
public:
typedef boost::shared_ptr<Foo> RcPtr;
void non_const_method() {}
void const_method() const {}
};
Having a const Foo::RcPtr doesn't prevent non-const methods from being invoked on the class, the following will compile:
#include <boost/shared_ptr.hpp>
int mai...
Very often I hear: use a profiler and unit test. How do I do that? I would be glad if someone would provide either links to websites with tutorials or recommend a good book. I'm using Visual Studio 2010 Ultimate.
...
First question here!
So, I am having some problems with pointers in Visual C++ 2008. I'm writing a program which will control six cameras and do some processing on them so to clean things up I have created a Camera Manager class. This class handles all operations which will be carried out on all the cameras. Below this is a Camera clas...
Is it possible to use member function pointers with template meta-programming? Such as:
class Connection{
public:
string getName() const;
string getAlias() const;
//more stuff
};
typedef string (Connection::*Con_Func)() const;
template<Con_Func _Name>
class Foo{
Connection m_Connect;
public:
Foo(){
cout << (m_...