c++

Writing to the middle of the file (without overwriting data)

In windows is it possible through an API to write to the middle of a file without overwriting any data and without having to rewrite everything after that? If it's possible then I believe it will obviously fragment the file; how many times can I do it before it becomes a serious problem? If it's not possible what approach/workaround is...

Why isnt int pow(int base, int exponent) in the standard C++ libraries?

I feel like I must just be unable to find it. Is there any reason that the c++ pow function does not implement the "power" function for anything except floats and doubles? I know the implementation is trivial, I just feel like I'm doing work that should be in a standard library. A robust power function (ie handles overflow in some consi...

Comparing objects with IDispatch to get main frame only (BHO)

I don't know if anyone familiar with BHO (Browser Helper Object), but an expert in c++ can help me too. In my BHO I want to run the OnDocumentComplete() function only on the main frame - the first container and not all the Iframes inside the current page. (an alternative is to put some code only when this is the main frame). I can't f...

Multiple constructors definitions with same name but different signatures (C++)

With the following code, I keep getting error C2535 when I compile. It's complaining that a member function already defined or declared. Rationnel.h ... class Rationnel { public: Rationnel(int); //Constructor Rationnel(int,int); //Constructor void add(const Rationnel); ... Rationnel.cpp ... //Constructor Rationnel::Rationnel(int ...

What is the best pratice to get a file attribute(such as read only), and security attribute(such as read deny write deny)?

I am programming in C++ MFC, windows. What is the best practice to get a file attribute(such as read only), and security attribute(such as read deny write deny) in windows XP, Vista, and Win7? and What is the best practice to modify a file attribuute and security attribute? Many thanks!!! ...

How to access member with same name in the inheritance

I have a question about how to access the member with the same name with inheritance. For example, class Base { public: int i; }; class Derived1 : public Base { public: int i; // how to access the i in the base class here? }; int main() { Derived1 d; cout<<d.i; //which is it is? //how...

Link TR1 on Ubuntu?

I have written a class using std::tr1::regex, and I don't know how to link it. I get (sorry for the large dump...) : $ g++ DictReader.cpp -std=c++0x /usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::tr1::regex_search(_Bi_iter, _Bi_iter, std::tr1::match_results<_Bi_iter, _Allocator>&, const std::tr1::basic_re...

C++ question on prime numbers.

Hello. I am trying to make a program that determines if the number is prime or composite. I have gotten thus far. Could you give me any ideas so that it will work? All primes will , however, because composites have values that are both r>0 and r==0, they will always be classified as prime. How can I fix this? int main() { int pNumbe...

how to use Application window? c++

i have been programming for sometime but all of my programming books have not really showed me how to use the Application window i always use the console window. i was looking at the Application project and i noticed that it has a .cpp file that is the main file but how do work with the window? i have tryed googleing it but i can't find ...

How to Get File security attribute in windows

I am using c++ MFC How can I get the file security attribute in windows, is there any handy api? Many thanks! ...

Additional macro support in clang?

Since LLVM/cLang is especially well designed. This seems like a great opportunity to augment the C/C++ macro/preprocessor system. Does anyone know of additional macro/preprocessor abilities added by Clang or side projects to make the macro system more powerful (like turing complete) Thakns! Note: I am asking about macros. Not C++ ...

On wxWidgets Mac version (wxMac) where is the setup.h file I need to modify?

I can't seem to find the right version of setup.h that gets used when building with ../configure, make. What directory is it? There seems to be tons of variations but I change them and the changes aren't used. Help. ...

Checking for underflow/overflow in C++?

Is there a general way to check for an overflow or an underflow of a given data type (uint32, int etc.)? I am doing something like this: uint32 a,b,c; ... //initialize a,b,c if(b < c) { a -= (c - b) } When I print a after some iterations, it displays a large number like: 4294963846. ...

String vectors not working as expected with newline and iterators? (C++)

I have a text file made of 3 lines: Line 1 Line 3 (Line 1, a blank line, and Line 3) vector<string> text; vector<string>::iterator it; ifstream file("test.txt"); string str; while (getline(file, str)) { if (str.length() == 0) str = "\n"; // since getline discards the newline character, replacing blank strings with newline ...

calling c++ code from c

Hi all, is there any way where I can call c++ code from a c code class a { someFunction(); }; how to call someFunction() from a c code. in other way I am asking how to avoid name mangling here regards Vinayaka Karjigi ...

Returning ifstream in a function

Here's probably a very noobish question for you: How (if at all possible) can I return an ifstream from a function? Basically, I need to obtain the filename of a database from the user, and if the database with that filename does not exist, then I need to create that file for the user. I know how to do that, but only by asking the user ...

Examples for Winsock?

What do you guys recommend for a resource for winsock? I have an assignment that we have only have a few days to do that needs to send a simple packet using UDP (and receive the same type of packet). I am fairly familiar with C# sockets but nothing with C++. Any tips or resources? ...

Using 32 bit g++ to build 64bit binaries on AIX

I am trying to build a 64 bit binary from C++ code using 32bit g++ compiler. I am getting the following errors while building: ============================================================================= => /usr/local/bin/g++ -shared -maix64 -fPIC -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bE:gcc_shr_lib.so.exp -o gcc_shr_lib.so gcc_shr_lib.o -L/u...

How to write C++ audio processing applications?

Hi everyone, I'm an Electronics and Telecommunications student, next to my graduation. I'm gonna work on a project that involves my knowledge about DSP, music and audio in general. I allready know all the basic mathematic instruments and all the stuff I need to manage it, such as FFT, circular convolution ecc ecc. I want to learn C++ ...

Should a C++ constructor do real work?

Possible Duplicate: How much work should be done in a constructor? I'm strugging with some advice I have in the back of my mind but for which I can't remember the reasoning. I seem to remember at some point reading some advice (can't remember the source) that C++ constructors should not do real work. Rather, they should init...