Typically, the way I'd define a true global constant (lets say, pi) would be to place an extern const in a header file, and define the constant in a .cpp file:
constants.h:
extern const pi;
constants.cpp:
#include "constants.h"
#include <cmath>
const pi=std::acos(-1.0);
This works great for true constants such as pi. However, I a...
Hi all,
I have a third-party legacy software that uses Automation to control MS Excel (using MFC/C++). The code is straightforward:
_ApplicationPtr xl;
HRESULT hr = xl.CreateInstance("Excel.Application");
This worked perfectly since Excel 2000, 2002 (XP), 2003 and 2007; however, after installing Office 2010, the CreateInstance call ...
Just having an conversation with collegue at work how to declare a variables.
For me I already decided which style I prefer, but maybe I wrong.
"C" style - all variable at the begining of function.
If you want to know data type of variable, just look at the begining of function.
bool Foo()
{
PARAM* pParam = NULL;
bool rc;
...
What would be the preferred method of pulling content from a remote database?
I don't think that I would want to pull directly from the database for a number of reasons.
(Such as easily being able to change where it is fetching the info from and a current lack of access from outside the server.)
I've been thinking of using HTTP as a pr...
Fairly new to socket programming, but I've been assigned with a whopper of project.
My issue is this: I try initiating an SSL handshake with both SSL_accept() and SSL_connect(), as well as renegotiating the handshake and then attempting to reconnect with SSL_renegotiate() and SSL_do_handshake() in succession, but all of these give me t...
here is code example for add two vectors using classes
#include <iostream>
using namespace std;
class CVector {
public:
int x,y;
CVector () {};
CVector (int,int);
CVector operator + (CVector);
};
CVector::CVector (int a, int b) {
x = a;
y = b;
}
CVector CVector::operator+ (CVector param) {
CVector temp;
te...
I'm making a game and I have a class called Man and a class called Block in their code they both need each other, but they're in seperate files. Is there a way to "predefine" a class? Like Objective-C's @class macro?
...
Working with exclusive-OR on bits is something which is clear to me. But here, XOR is working on individual characters. So does this mean the byte which makes up the character is being XORed? What does this look like?
#include <iostream.h>
int main()
{
char string[11]="A nice cat";
char key[11]="ABCDEFGHIJ";
for(int x=0; x<10; ...
hello.
Can you please tell me if such code is correct (according to standard):
struct array {
int data[4];
operator const int*() const { return data; }
};
void function(const int*) { ... }
function(array()); // is array data valid inside function?
Thank you
...
<h1>Abasement</h1>
<hw>A*base"ment</hw> <tt>(#)</tt>,
<tt>n.</tt>
<ety>[Cf. F. <ets>abaissement</ets>.]</ety>
<def>The act of abasing, humbling, or bringing low; the state of being abased or humbled;humiliation.</def>
I have a file with definitions of words like this, enclosed in tags. I'd like to convert this to an SQLite database ...
Here s what I'm doing in a nutshell.
In my class's cpp file I have:
std::vector<std::vector<GLdouble>> ThreadPts[4];
The thread proc looks like this:
unsigned __stdcall BezierThreadProc(void *arg)
{
SHAPETHREADDATA *data = (SHAPETHREADDATA *) arg;
OGLSHAPE *obj = reinterpret_cast<OGLSHAPE*>(data->objectptr);
for(unsigne...
I am creating a logging facility for my library, and have made some nice macros such as:
#define DEBUG myDebuggingClass(__FILE__, __FUNCTION__, __LINE__)
#define WARING myWarningClass(__FILE__, __FUNCTION__, __LINE__)
where myDebuggingClass and myWarningClass both have an overloaded << operator, and do some helpful things with log me...
Hi,
Is there a way to save opencv objects to database (like oracle, mysql a.s.o) instead of xml file ?
CvSave is like a blackbox.
Thx
...
Is their any C popen() equivalent in C++ to ?
...
I am able to call C++ code from Java using SWIG but I can't find any documentation on how to do the reverse (call Java from C++).
The official SWIG documentation says (http://www.swig.org/Doc1.3/Java.html#java_overview):
"SWIG enables a Java program to easily call into C/C++ code from Java. Historically, SWIG was not able to generate a...
I'm not sure this is possible, but is there a way, using template programming magic, to define a function that has different return values depending on what input it takes?
Potentially:
template<typename resultType>
resultType GetResult(const std::string &key); // where the value of key may change resultType
template<typename keyType,...
I have to add a default int& argument (Eg iNewArument) to an existing function defnintion in a header file:
What is the synatax to init the last argument to make it take a default value ?
..
virtual int ExecNew
(int& param1, int& RowIn,int& RowOut, char* Msg = '0',
bool bDebug=true, int& iNewArgument = NULL ) = 0 ;
.
...
Taking the following snippet as an example:
struct Foo
{
typedef int type;
};
class Bar : private Foo
{
};
class Baz
{
};
As you can see, no virtual functions exist in this relationship. Since this is the case, are the the following assumptions accurate as far as the language is concerned?
No virtual function table will be creat...
Since maps dont allow duplicate values . Are there any other containers that are part of C++ standard library that allow duplicates that store values by key value pair?
...