Hi,
Consider the following class:
class A {
char *p;
int a, b, c, d;
public:
A(const &A);
};
In the above I have to define a copy constructor in order to do a deep copy of "p". This has two issues:
most of the fields should simply copied. Copying them one by one is ugly and error prone.
the more important problem is that whene...
I define a std::map in static library .a like this
//////////////////////////////////////
#import <map>
class CCImage;
class ImageArray{
std::map<int,CCImage*> mapCCImages;
private:
int imagesLength;
public:
ImageArray();
~ImageArray();
int getImageLen();
bool addCCImage(int key,CCImage * texture,bool replace = true);
CCImage *g...
I have a bunch of C code. I have no intention to convert them into C++ code.
Now, I would like to call some C++ code (I don't mind to modify the C++ code so that they are callable by C code).
class Utils {
public:
static void fun();
}
class Utils2 {
public:
static std::wstring fun();
}
If I tend to call them with the followi...
Hi,
I use this code to validate some properties of a set of Qt objects in ChaiScript:
/// initialize the engine
boost::shared_ptr<chaiscript::ChaiScript> chai;
chai.reset(new chaiscript::ChaiScript());
std::cout << "ChaiScript engine created!!!" << std::endl;
///
/// register elements
//
assert(ui->che...
I once started C++ about 3 years ago, and my skill literally frozen up at that point, because I can't find a good practical reading sources that can fill the gap between beginner and expert. I tried to read and understand other expert's open sources code but most of their implements are just too confusing, and most of the time requires a...
Hi All,
My c++ application developed in Visual Studio 2008 crashes at some memory location. It is showing memory access violation erroe like,
Unhandled exception at 0x650514aa in XXX.exe: 0xC0000005: Access violation reading location 0x00000004.
how I can get the variable name assigned to 0x650514aa this memory location. Or how to deb...
I was looking into how std::tr1::shared_ptr<> provides the ability to cast to bool. I've got caught out in the past when trying to create a smart pointer that can be casted to bool as the trivial solution, ie
operator bool() {
return m_Ptr!=0;
}
usually ends up being implicitly castable to the pointer type (presumably by type promo...
i used qt to make an application in the tray. on my pc its a good project and i see the icon in the traybar, but when i release it to give it to sombody else they dont see the icon, its just an invissible square that can be used but it dont show the icon. but on my pc it shows the icon. :S i know it sounds weird but does anybody know how...
I noticed while reading through my code that I have a static member function which alters a private member of its class through a pointer to an instance of said class.
It compiles and functions without issue, but I just wanted to know whether or not it was kosher to edit a private variable in this way, from a member but static function,...
Suppose I create a file for writing like this:
std::ofstream my_file("filename", std::ios_base::out | std::ios_base::trunc);
How are the permissions of this file determined? I've had a program running overnight generating files about once a minute - some are 0644 but others are 0660, and there's nothing in my code that should make it ...
Hello,
I have a C++ application which dynamically loads plug-in DLLs. The DLL sends text output via std::cout and std::wcout. Qt-based UI must grab all text output from DLLs and display it.
The approach with stream buffer replacement doesn't fully work since DLLs might have different instances of cout/wcout due to run-time libraries dif...
I have the following code (simplified):
ostringstream oss;
oss << "Text ";
oss << hex << uppercase;
oss.width(8);
oss.fill('0');
oss << var1 << " ";
oss << var2 << " ";
oss << dec << nouppercase;
oss.width(1);
oss << var3 << " another text." << endl;
string result = oss.str();
// work with result...
Where var1, var2 are unsigned...
Hi,
Is there a way in C++ to effectively create a closure which will be a function pointer? I am using the Gnu Scientific Library and I have to create a gsl_function. This function needs to effectively "close" a couple of parameters available when I create it. Is there a nice trick to create a closure so that I don't have to pass all of...
Hello
This is a question for experienced C/C++ developpers.
I have zero knowledge of compiling C programs with "make", and need to modify an existing application, ie. change its "config" and "makefile" files.
The .h files that the application needs are not located in a single-level directory, but rather, they are spread in multiple su...
I'm working on a library that defines a client interface for some service. Under the hood I have to validate the data provided by users and then pass it to "engine" process using Connection class from another library (note: the Connection class isn't known to the users of our library). One of my colleagues proposed using PIMPL:
class Cl...
Does anyone know of any C++ class which are not binary moveable?
In other words, do you know any class where this results in memory-leak or undefined behaviour?
{ // New scope
// Allocate some memory
unsigned char data1[sizeof(MyClass)];
unsigned char data2[sizeof(MyClass)];
// Create an instance of the class
::new (data1) MyClass();
/...
hi;
I have a C++ code (mini search engine).
I wanna make GUI.But i don't know how to add my code to the QT to create the GUI .
note:my code contains (test.cpp , linkedlist.h , table.h)
thanks.
...
Hi,
I'm in the process of writing a kind of runtime system/interpreter, and one of things that I need to be able to do is call c/c++ functions located in external libraries.
On linux I'm using the dlfcn.h functions to open a library, and call a function located within. The problem is that, when using dlsysm() the function pointer retur...
int main()
{
char* a = " 'Fools\' day' ";
char* b[64];
sscanf(a, " '%[^']s ", b);
printf ("%s", b);
}
--> puts "Fools" in b
Obviously, I want to have "Fools' day" in b. Can I tell sscanf() not to consider escaped apostrophes as the end of the character sequence?
Thanks!
...
I have a constructor, that receives a character pointer. If it is empty, I need to set its member variable to NULL, however, the program crashes on exit when I try to.
I have verified that it gets to the line where it sets it to NULL and that is the cause of the crash.
I've tried the following:
val = NULL;
val = 0;
val = "";
Thos...