c++

header file without source file

i have written the body of the function in the header file and so do not have a source file. when i tried running my project in visual studio .. i got an error: Cannot open source file: No such file or directory. How do I make visual studio understand that the definitions of the function are within the header itself? ...

CS senior project ideas involving Unix system programming

I know there are a number of questions about senior project ideas but I am specifically looking for a project that involves Unix system programming in C or (preferably) C++. I have the book which I used for one quarter but haven't had a chance to use since. I want to find a project that will give me as much experience with Unix system ...

Determining maximum possible alignment in C++

Is there any portable way to determine what the maximum possible alignment for any type is? For example on x86, SSE instructions require 16-byte alignment, but as far as I'm aware, no instructions require more than that, so any type can be safely stored into a 16-byte aligned buffer. I need to create a buffer (such as a char array) wh...

How do you understand dependent names in C++

I come across this term "dependent names" typically in the context of templates. However, I rarely touch the latter. Thus naturally would like to know more about the concept of dependent names. How do you understand it in the context of templates and outside of them? example are critically encouraged! ...

File echo loop with extra final iteration

Why do I get an extra iteration (extra line printed) when this code completes? Does there need to be an extra newline at the EOF? I would prefer not having to add extra/special characters to mark the EOF. #include <iostream> #include <fstream> #include <string> using namespace std; int main(){ ifstream infile("dictionar...

OpenGL 3.2 Programming Guide?

Most resources available online are very outdated. Specifically, they are all about OpenGL 2 which matches to DirectX 9. The current specification is 3.2 which is equivalent (or, well, very close) to DirectX 10 (11). But the specification itself is very hard to read. In contrast, DirectX SDK is a wonderful piece of documentation, sample...

Call stack corruption between boundaries

This feels a lot like finding a needle in a hay stack but here goes. I'm building a Windows Mobile 6.1 application. Specifically I'm trying to port over the OpenCV framework. Having successfully (doubtfully) compiled OpenCV for the ARM4I architecture, I'm trying it out in a simple hello world style application. From my WinCE .EXE I'm c...

C++: Casting for user defined types

How can I get the same handeling of casting for user-defined types as built in, eg: float a = 5.4; std::string s = a;//error, no conversion avaible int x = a;//warning, possible data loss int y = (int)a;//fine int z = static_cast<int>a;//fine float b = c;//warning, possible data loss Now say I have my own Int and Float class, how do I...

Get path of executable

I know this question has been asked before but I still haven't seen a satisfactory answer, or a definitive "no, this cannot be done", so I'll ask again! All I want to do is get the path to the currently running executable, either as an absolute path or relative to where the executable is invoked from, in a platform-independent fashion. ...

Floating point stack handling with floating-point exceptions turned on

I'm running into an issue with floating point exceptions turned on in Visual Studio 2005. If I have code like this: double d = 0.0; double d2 = 3.0; double d3 = d2/d; and if I register an SEH handler routine, then I can easily turn the div-by-zero into a C++ exception and catch it. So far so good. However, when I do this, the f...

How can I extend a lexical cast to support enumerated types?

I have the following function that will convert a string into a numeric data type: template <typename T> bool ConvertString(const std::string& theString, T& theResult) { std::istringstream iss(theString); return !(iss >> theResult).fail(); } This does not work for enumerated types, however, so I have done something like this: ...

Templates and headers question

The compiler says it can't find the reference for the function when I do this: // link.h template <class T> T *Link(T *&, T *(*)()) // link.cpp template <class T> T c:Link(T *&ChildNodeReference, T *(*ObjectCreator)()){ } If I implement inside the class on the header it goes smoothly. Please, I will work on the header until som...

C++ templated functors

Hi, I was wondering if anyone can help me with functors. I dont really understand what functors are and how they work I have tried googling it but i still dont get it. how do functors work and how do they work with templates ...

Garbage values from third class object C++

string str = ""; for ( int x = 0; x < str.length(); x++ ); ...

Split large file without copy?

Question: Are there Windows API calls (perhaps NTFS only) which allows one to split a very large file into many others without actually copying any data (in other words, specify the logical breakpoints between joined files, with file names and sizes)? Examples: SetFileValidData, NtSetInformationFile Scenario: I need to programatically...

Qt QPlainTextEdit background

I want to change the background color of a QPlainTextEdit, how do I do this? ...

Idiomatic way to do list/dict in Cython?

My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use less encumbered data structur...

Decrypting data files with wincrypt. Having trouble. Example shows CBase64Utils?

I need to decrypt some data files with wincrypt and examples are few and far between online. The most solid example I've found is here. However, this is using all sorts of types I cannot seem to find information about (CBase64Utils, CString, etc). I am reading the final solution, trying to understand the process, and have come to this...

Garbage values when C++ Operator Overloading

Im just getting garbage values. And it is wierd the debugger shows the correct values. But its printing weird stuff insted... this frist part is fine. Essentially, It just takes me to my problem. I have what I need to print inside that h.hashtable[hashIndex] array. ostream& operator<<(ostream& out, const hashmap& h) { const cha...

Why use if-else if in C++?

Why would you use if-else statements if you can make another if statement? Example with multiple ifs: input = getInputFromUser() if input is "Hello" greet() if input is "Bye" sayGoodbye() if input is "Hey" sayHi() Example with else-if: input = getInputFromUser() if input is "Hello" greet() else if input is "Bye" ...