Hi,
I have a header file which contains a member variable declaration of a static char array:
class ABC
{
public:
static char newArray[4];
// other variables / functions
private:
void setArray(int i, char * ptr);
}
In the CPP file, I have the array initialized to NULL:
char ABC::newArray[4] = {0};
In the ABC constructor, I need ...
I am just starting to learn C++ (coming from a Java background) and I have come across something that I can't explain. I am working through the C++ Primer book and doing the exercises. Every time I get to a new exercise I create a new .cpp file and set it up with the main method (and any includes I think I will need) e.g.:
#include <l...
Boost.Asio documentation suggests the following exception handling pattern:
boost::asio::io_service io_service;
...
for (;;)
{
try
{
io_service.run();
break; // run() exited normally
}
catch (my_exception& e)
{
// Deal with exception as appropriate.
}
}
The problem with it is that the context of exception is lo...
Hey there,
I am attempting to open Firefox using C++ on Linux (Ubuntu). However, I get an segmentation fault. What am I doing wrong, and what should I do?
std::cout << system("/usr/bin/firefox") << std::endl;
I hope to hear from you.
Kind regards,
Machiel
...
I'm using Visual Studio 2010 Beta 2 (also tried with NetBeans), and I'm having a segmentation fault in the following code:
// One of the @link s20_3_3_comparisons comparison functors@endlink.
template <class _Tp>
struct less : public binary_function<_Tp, _Tp, bool>
{
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return _...
I've been trying to solve this and I found an equation that gives the possibility of zero division errors. Not the best thing:
v1 = (a,b)
v2 = (c,d)
d1 = (e,f)
d2 = (h,i)
l1: v1 + λd1
l2: v2 + µd2
Equation to find vector intersection of l1 and l2 programatically by re-arranging for lambda.
(a,b) + λ(e,f) = (c,d) + µ(h,i)
a + λe = c +...
Hi,
in this article about boost spirit semantic actions it is mentioned that
There are actually 2 more arguments
being passed: the parser context and a
reference to a boolean ‘hit’
parameter. The parser context is
meaningful only if the semantic action
is attached somewhere to the right
hand side of a rule. We will see ...
I'm trying to create a variable length function (obviously, heh) in C++, and what I have right now works, but only for the first argument. If someone could please let me know how to get this working with all the arguments that are passed, I would really appreciate it.
Code:
void udStaticObject::accept( udObjectVisitor *visitor, ... )
{...
The official examples of exposing a Point class seem to assume that there will be a fixed number of instances of it in your program. It is not clear how new instances are allocated in the C++ code, when new is called in Javascript.
How would you expose a class that can have multiple instances? For example, an Image class:
var img1 = ne...
I am very confused about the const version and non-const version member function like below:
value_type& top() { return this.item }
const value_type& top() const { return this.item }
What is the difference between these two functions? In what situation would they be used?
...
Hi all,
i am a complete nobbie to BHO and C++.
This is what i want to achieve.
Using various code samples, i have been successful in installing a BHO in my Internet Explorer. I am currently making use of the Invoke method to search for DISPID_HTMLDOCUMENTEVENTS2_ONCLICK and have been successful in capturing the event.
How can i acces...
int score = 0;
char* fixedscore=(char*)score;
.
.
.
imgTxt = TTF_RenderText_Solid( font, fixedscore, fColor );
^^ This doesn't work - looks like fixedscore is empty or doesn't exists.
int score = 0;
char* fixedscore=(char*)score;
.
.
.
imgTxt = TTF_RenderText_Solid( font, "Works fine", fColor );
^^ Works fine, but...
I guess conver...
#include"iostream"
class CMessage
{
public:int a;
CMessage(){}
~CMessage(){}
};
void Testing(CMessage *f_pMessage)//l_pMessage is output parameter
{
f_pMessage = new CMessage();
f_pMessage->a = 1;
}
int main()
{
CMessage *l_pMessage =NULL;
Testing(l_pMessage);
std::cout<<l_pMessage->a;//getting l_pMessag...
i am doing project on hand written recognition systems.i need help where to start.......
...
I'd like to create various network errors during testing. I'm using the Berkely sockets API directly in C++ on Linux. I'm running a mock server in another thread from within Boost.Test which listens on localhost.
For instance, I'd like to create a timeout during connect. So far I've tried not calling accept in my mock server and sett...
Hi. Here is my code function:
void ReportHistory::update(void)
{
ui.output->clear();
ui.output->setCurrentFont(QFont("Arial", 8, QFont::Normal));
QString title = "My Title";
QStringList headers = QString("Header1,Header2,Header3,Header4,Header5,Header6").split(",");
QString html = QString(
"<html>" \
"<head>" \
"<meta Cont...
Hi there,
I was wondering if there is a possibility to catch errors like this in C++:
object* p = new object;
delete p;
delete p; //this would cause an error, can I catch this?
Can I check if the pointer is valid?
Can I catch some exception?
I know I could set the pointer p to NULL after the first object deletion. But just imagin...
Hello,
I'm trying to marshall unsigned char** (which is in a C++ interface) in order to call the method from C#.
How can this be done? Is there a list where are C++ data types and C# data types?
Thanks!
...
I am coding in c++ windows.
INT64 dirID = -1;
CString querySQLStr = _T("");
querySQLStr.Format(L"select * from ImageInfo where FolderPath=%64d;", dirID);
querySQLStr always like this:
select * from ImageInfo where FolderPath= 1214;
is it right to use %64d?
Many Thanks
...
I am trying to print the address of a virtual member function.
If I only wants to print the address of the function I can write:
print("address: %p", &A::func);
But I want to do something like this:
A *b = new B();
printf("address: %p", &b->func);
printf("address: %p", &b->A::func);
however this does not compile, is it possible t...