How to check if the binary representation of an integer is a palindrome?
How to check if the binary representation of an integer is a palindrome? ...
How to check if the binary representation of an integer is a palindrome? ...
Is there any way to return an array from a function? More specifically, I've created this function: char bin[8]; for(int i = 7; i >= 0; i--) { int ascii='a'; if(2^i-ascii >= 0) { bin[i]='1'; ascii=2^i-ascii; } else { bin[i]='0'; } } and I need a way to return bin[]. ...
How do I raise a number to a power? 2^1 2^2 2^3 etc... ...
I am looking at the .h file of a Wrapper class. And the class contains one private member: T* dataPtr; (where T is as in template < class T > defined at the top of the .h file) The class provides two "* overloading operator" methods: T& operator*() { return *dataPtr; } const T& operator*() const { return *dataPtr; } Both sim...
I heard Qt API is written in pretty outdated C++ language. Is it true? Are there any plans to make it use more modern C++ language? Are there any official information on this? Are there any projects with the aim to wrap current Qt API constructs with more modern C++? UPDATE That's more to this question than templates and that's not the...
Hi, I have a C++ Windows application myapp.exe which loads several plug-ins. Plug-ins need to find the path to their DLLs. I can use GetModuleFileName for this, but it need the handle for the plug-in DLL. I don't know where to get this handle. GetModuleHandle(NULL) returns the handle to the executable. One option is to use GetModuleHa...
I have two questions: 1) Why is my code adding a carriage return at the beggining of the selected_line string? 2) Do you think the algorithm I'm using to return a random line from the file is good enough and won't cause any problems? A sample file is: line number one # line number two My code: int main() { srand(time(0)); i...
Ok so i've messed with games before, but now i would like to make a trainer only problem is that there memory adresses changes every time i play it on a different computer or restart the game. Now i need to find a pointer but have no idea how. So how do i find the pointer to the adress for ammo for any weapon with a memory scanner like ...
Some code for context: class WordTable { public: WordTable(); ~WordTable(); List* GetListByAlphaKey(char key); void AddListByKey(char key); bool ListExists(char key); bool WordExists(string word); void AddWord(string word); void IncrementWordOccurances(string word); void Print(); private: List *_listArray[33]; int...
I have heard that C++ offers no native support for multithreading. I assume that multithreaded C++ apps depended on managed code for multithreading; that is, for example, a Visual C++ app used MFC or .NET or something along those lines to provide multithreading capability. I further assume that some or all of those managed-code capabil...
I'm working on a class assignment that started small, so I had it all in one file. Now it's gotten bigger and I'm trying to separately compile main, functions, and classes (so all the classes are together in one .h and one .cpp) I have one class B, which is the parent of a lot of others and comes first in the file. One of its data member...
If I have a functor class with no state, but I create it from the heap with new, are typical compilers smart enough to optimize away the creation overhead entirely? This question has come up when making a bunch of stateless functors. If they're allocated on the stack, does their 0 state class body mean that the stack really isn't change...
I've heard a lot of good comments about Boost in the past and thought I would give it a try. So I downloaded all the required packages from the package manager in Ubuntu 9.04. Now I'm having trouble finding out how to actually use the darn libraries. Does anyone know of a good tutorial on Boost that goes all the way from Hello World to ...
Is there a C++ function to turn off the computer? And since I doubt there is one (in the standard library, at least), what's the windows function that I can call from C++? Basically, what is the code to turn off a windows xp computer in c++? ...
The fragment below is from a VC++ 2008 Express Edition. Say, I have a class with a member that is a struct. I am trying to define default values for the member variables of this class. Why this does not work? struct Country{ unsigned chart id; unsigned int initials; std::string name; }; class world{ private: Country ...
I've just installed the windows7 RC in a VM and I'm attempting to build our existing projects on the new OS. The projects are c/c++ based and I'm using visual studio 2008. In order to build these projects I need to register several tlb files that are referenced within the code base. However, I've just discovered, that regtlib.exe appea...
For most of my development work with Visual C++, I am using partial builds, e.g. press F7 and only changed C++ files and their dependencies get rebuilt, followed by an incremental link. Before passing a version onto testing, I take the precaution of doing a full rebuild, which takes about 45 minutes on my current project. I have seen m...
I am preaty new with QT. I want to respond to linkClicked in QWebView... I tried connect like this: QObject::connect(ui->webView,SIGNAL(linkClicked(QUrl)),MainWindow,SLOT(linkClicked(QUrl))); But I was getting error: C:/Documents and Settings/irfan/My Documents/browser1/mainwindow.cpp:9: error: expected primary-expression before ',...
Hello. Although I consider myself an experienced programmer (lead programmer of 2 commercially released games), I feel lost now that I have started using C++ for my next project. Right now I want to create a class to read/encrypt/decrypt JSON-like text-based data files (a custom format I have designed for my needs). Let's say it's calle...
I'm developing a C api for some functionality written in C++ and I want to make sure that no exceptions are propagated out of any of the exported C functions. The simple way to do it is making sure each exported function is contained in a: try { // Do the actual code } catch (...) { return ERROR_UNHANDLED_EXCEPTION; } Let's say...