c++

Is is possible to dynamically have methods aliases in a c++ / qt class objects?

Supposing that I have a C++ class X (a Qt qobject, por exemple), with a method, let's say, QMap handleDynMethods(QString alias). if x is a instance of X class, I wish method handleDynMethods(QString alias, QMap parameters) be invoked when I do x->anyAliasName(parameters), producing x->handleDynMethods("anyAliasName", parameters). Is it p...

C++/Qt Multiline strings; also, multiple queries

Hello, Two [hopefully] quick questions regarding C++/Qt. Is the following proper for writing a string on multiple lines? QString strQuery; strQuery="\ CREATE TABLE foo\ (bar integer primary key,\ baz varchar(20))"; I believe this is right, but in Qt Creator it doesn't highlight as though it is one ...

A method which can only be invoked when referring to base class? C++

Say I have an abstract class class NecessaryDanger { public: virtual void doSomethingDangerous() =0; } and a class that is derived from this class: class DoesOtherStuff : public NecessaryDanger { //stuff void otherMethod(); void doSomethingDangerous(); } is there a way I can only allow access of doSomethingDange...

How to obtain a value based on a certain probability

I have some functions which generate double, float, short, long random values. I have another function to which I pass the datatype and which should return a random value. Now I need to choose in that function the return value based on the passed datatype. For example, if I pass float, I need: the probability that the return is a float ...

Does this code check for endianess ?

Hi I heard in little endian, the LSB is at starting address and in Big endian MSB is at starting address. SO I wrote my code like this. If not why ? void checkEndianess() { int i = 1; char c = (char)i; if(c) cout<<"Little Endian"<<endl; else cout<<"Big Endian"<<endl; } ...

lib curl in c++ disable printing

hello, i got a small program from http://curl.haxx.se/ and while i run it always prints the webpage how can i disable the printing function #include <iostream> #include <curl/curl.h> using namespace std; int main() { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, C...

How can I study and practices on C++ pointer?

I'm moving from C# to C++, one of priority topic for me is pointer. I'm reading some book and some blog post about pointer and I understand its basic concept. Now I want to learn about pointer by practicing it. I try to search on google, unfortunately not thing found. Are there anything can help me study and practices on C++ pointer? ...

stack growth direction

So from my previous memmove question I would like to know how to find direction of stack growth. void stackDirection(int* i) { int j; if(&j>i) cout<<"Stack is growing up \n"<<endl; else cout<<"Stack is growing down \n"<<endl; } int main() { int i=1; stackDirtection(&i); ...

Unsure of a Declaration in C++

I am currently reading some C++ source code, and I came across this: double **out; // ... lots of code here // allocate memory for output of each neuron out = new double*[num]; Not entirely sure what it does, or what it means. Is it a pointer... is at an array? There is also the following: // vector of weights for each neuron...

difference between c's expression and c++'s expression

int main() { int i=3; (++i)++; printf("%d",i); } This programs works with g++ compiler but not gcc. If i write i++++ or ++i++ it doesn't work in cpp also. I think there is difference between c-expression and c++-expression. Can somebody explain about L-value and R-value ? ...

C++: Where to write the code documentation: in .cpp or in .hpp files?

Where is it customary to write the in-code documentation of classes and methods? Do you write such doc-blocks above the corresponding class/method in the header (.hpp) file, or within the source (.cpp) file? Is there a widely respected convention for such things? Do most C++ projects do it one way rather than the other? Or sho...

How Can I call a C++ Win32 DLL from another C++ win32 Console Application

What is my main concern is , I am able to write a C++ dll using VC++ . Now the dll is present in the Debug folder. How can I use my DLL in other C++ Console Application. How to add reference or link the DLL to the application. Another point, While creating a DLL , The VC++ wizard gives me thre option: An Empty DLL project A Simple DL...

Visual studio 2008 release build : application crashes on basic string or basic pointer operations

I have a application compiled in Visual studio 2008,which runs fine in debug build. In release build , the application crashes when std::wstring assignment is done or when shared pointer is accessed. Any idea why this happens in release build. crash at : eg: m_name = name; //m_name and name are of type std::wstring ...

Error building legacy code with VS 2005

Trying to build a legacy code in VS2005 and get errors in VC header files. d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C2065: '_Sb' : undeclared identifier d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2176) : see reference to class template instantiation 'std::istreambuf_iterator<_Elem,_Tra...

create header files in c++

i have following question is there possibility in c++ create header files using following rules let's take header #include "sum.h"> where in sum.h i will declare functions or procedure and then use it in .cpp files? thanks ...

Problem using libcurl: it does not appear to get the entire page

I am having difficulty getting started with libcurl. The code below does not appear to retrieve the entire page from the specified URL. Where am I going wrong? #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> using namespace std; char b...

how to allow a process created by another process, use a part of memory of the creator process ?

I got two console processes that second one is created by first one using the API below: BOOL WINAPI CreateProcess( __in_opt LPCTSTR lpApplicationName, __inout_opt LPTSTR lpCommandLine, __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes, __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, __in BOOL bInherit...

question about link and include of different vers of a lib

Hi, Is it a problem if I have an executable and a library use different versions of another library. Example: If I have an executable: A.exe, and it basically wraps and depends on a static library A.lib Both A.exe and A.lib need another library B.lib If I have a situation like this: The A.lib library includes B.lib version ...

How does the Import Library work? Details?

Hi guys, I know this may seem quite basic to geeks. But I want to make it crystal clear. When I want to use a Win32 DLL, usually I just call the APIs like LoadLibrary() and GetProcAdderss(). But recently, I am developing with DirectX9, and I need to add d3d9.lib, d3dx9.lib, etc files. I have heard enough that LIB is for static linking...

Should Mutex's lock/unlock functions be "const" ?

Hello, I am maintaining a library that contains a Mutex class. I cannot decide if the lock() and unlock() functions exposed by this class should be const or not. I looked for similar code on the Web, and could find both implementations. First implementation, lock() and unlock() are not const. It means someone who uses the Mutex class i...