Hello. I would like to ask you on what does the offset of the table of virtual functions for a class depend? I mean, from what I've read it at least depends on compiler, but does it varies from class to class?
Edit: by offset I mean the position of the table relative to the address of the owner object.
Edit: example code:
void **vtabl...
This is a seemingly simple problem, but I'm having difficulty coming up with an answer. I have a float value that needs to be put into a std::string, like so:
float val = 2.5;
std::string my_val = val; // error here
Obviously they're of different types. How do I convert from float to string?
All help is appreciated.
...
It would be a very simple question (could be duplicated), but I was unable to find it.
Win32 API provides a very handy set of atomic operations (as intrinsics) such as InterlockedIncrement which emits lock add x86 code. Also, InterlockedCompareExchange is mapped to lock cmpxchg.
But, I want to do that in Linux with gcc. Since I'm worki...
hi
I am looking for visualization framework, preferably that has simple interface for simple things, with C++ implementation. my requirements are very simple - plotting matrixes (as a debugging tool), so i do not really care about performance or appearance, and 2D is enough for me.
i had used VTK under octave, and it worked pretty well...
Is there something similar to Java/.NET serialization for C++?
...
Please help me with the following problem:
I have the following classes:
class ChemicalElement
{
private:
std::string _name;
void Init(const std::string& name);
public:
ChemicalElement(const std::string& name);
ChemicalElement(const ChemicalElement& ce);
};
class CombinationRule
{
private:
ChemicalElement _ce1;
...
I am running a C++ program which uses a class from another .cpp file. The class only has a constructor. It works when I test it separately. The main program compiles,but when I run it, I have a bug in the constructor. Any one can think of any situation that could happen? Thanks.
I guess I just run the code in terminal, and it is fine. ...
Ok, I'm relatively new to using the mysqlpp library that is used in Visual Studio to connect to a MySQL database and am having trouble trying to convert a vector of type mysqlpp::String to a vector of type int. Does anyone have any experience with mysqlpp and would mind helping me out a little? I've posted an example of what I'm basicall...
#include <stdio.h>
int main(void){
unsigned a[3][4] = {
{2,23,6,7},
{8,5,1,4},
{12,15,3,9}
};
printf("%u",*((int*)(((char*)a)+4)));
return 0;
}
The output in my machine is the value at a[0][1] i.e 23.Could somebody explain how is this working ?
Edit: Rolling Back to old yucky code,exactly what was presented to me :P
...
Starting with Win7/Server2008R2 the GetNumaProximityNode(Ex) function is available. It should help retrieve the distance between NUMA nodes, but I can't understand from the documentation (http://msdn.microsoft.com/en-us/library/ms683206(VS.85).aspx) how it's supposed to work. It says that you give it a distance, and it returns the corres...
I'm trying to get a better grasp on pointers. My class assignment was to create the function for the prototype void OpenFile(const char *fileName, ifstream &inFile).
void OpenFile(const char *fileName, ifstream &inFile)
{
inFile.open(FILENAME, ios_base::in);
if (!inFile.is_open()) {
cerr << "Could not open file " << fileNam...
Problem:
class Base {
public:
Base(Base* pParent);
... implements basic stuff...
};
class A : virtual public Base {
public:
A(A* pParent) : Base(pParent) {}
...
};
class B : virtual public Base {
public:
B(B* pParent) : Base(pParent) {}
...
};
class C : public A, public B {
public:
C(C* pParent) : A(pParent), B(pParent) {} ...
I'm searching for a tutorial to load a XML file, read it, change it and finally save it with C++. I'm using Linux Ubuntu and tried to use Xerces. With Google and much time, I could only load an XML File:
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc...
suppose i have a class engin and i inherit a class car from engin class
class engin
{
public:
engin(int nobofcylinders);
void start();
};
class car:private engin
{
public:
car():e(8){}
void start()
{
e.start();
}
private:
engin e;
};
now the same can be do...
Hi, I've only just recent began learning C++ and am having a little issue with while loops when the condition for the while loop is an input, of type double, from the user. I understand that if the user doesn't enter a value compatible with the double type then the loop is automatically broken. The issue is my console application exits u...
I want to append some binary data to the end of my executable. This is just to make my program into a single file. I tried using UpdateResource but I hit some bug inside it with my specific data, so I have to use another solution. So I need to know the original file size to determine if there is actually any data appended to it. Is it po...
#include <iostream>
using namespace std;
/*Use void functions, they perform some action but do not return a value*/
//Function Protoype, input,read in feet and inches:
void input (double& feet, double& inches);
//Function Prototype, calculate, calculate with given formulae.
void calculate(double& feet, double& inches);
//Function Proto...
I did this problem [Project Euler problem 5], but very bad manner of programming, see the code in c++,
#include<iostream>
using namespace std;
// to find lowest divisble number till 20
int main()
{
int num = 20, flag = 0;
while(flag == 0)
{
if ((num%2) == 0 && (num%3) == 0 && (num%4) == 0 && (num%5) == 0 && (num%6) == 0
&...
Hello, I have something like this:
void Test(void)
{
char errorMessage[256];
spintf(errorMessage,... blablabla);
throw new CustomException(errorMessage);
}
Will this be a memory leak because errorMessage will be not freed? Or will this cause an exception when accessing the message of the exception inside a try{}catch beca...
I have created a global Keyboard hook.
Hook is created in a DLL.
#pragma comment(linker, "/SECTION:.SHARED,RWS")
#pragma data_seg(".SHARED")
static HHOOK hkb=NULL;
static CMyFile *pLF;
#pragma data_seg()
HINSTANCE hins = NULL;
extern "C"
LRESULT __declspec(dllexport) __stdcall CALLBACK KeyBoardHookProc(
int nCode,
WPARAM w...