c++

Why don't I have setTextFormat in my QTextEdit?

Hi, Anyone have any Idea why I don't have this function (setTextFormat) in my QTextEdit class? Thanks in advance. ...

Calculating time by the C++ code

I know this question has been asked few times over SO but none of them is really helping me out, so asking again. I am using windows xp and running visual studio c++ 2008. All the code which i am looking is using time.h but i think may be its not working correctly here, because results are making me suspicious. So this is what i want....

C++ template class and template function

If I have one template class and template function like this template <class T> T getMax (T a, T b) { return (a>b?a:b); } template <class T> class GetMax { public: static T getMax(T a, T b) { return (a>b?a:b); } }; Why are these not valid? x=getMax(1, '2'); but these are valid x=getMax(1...

fstream >> int failing?

Any idea why the following would fail? std::fstream i(L"C:/testlog.txt", std::ios::binary | std::ios::in); int test = 0; i >> test; fail() is returning true. The file exists and is opened. I checked i._Filebuffer._Myfile._ptr and it is pointer to a buffer of the file so I don't see why it is failing. ...

How to encode video?

I want to write a video encoding. What do I need to do? ...

Virtual Table C++

I read a lot of people writing "a virtual table exists for a class that has a virtual function declared in it". My question is, does a vtable exists only for a class that has a virtual function or does it also exist for classes derived from that class. e.g class Base{ public: virtual void print(){cout<<"Base Print\n";} };...

OpenMP questions

Hi, I want to parallelize a loop in a class member function. However there are two errors in the code: class myclass { public: int _k; void f(int nb_examples, int nb_try) { int i; int ks[nb_try]; // assignment to elements in ks omp_set_num_threads(_nb_threads); #pragma omp parallel shar...

Translate a code using pointer, to Assembly in Pascal - Delphi

Hi all. I have this code below, and I want to translate it to ASM, to use in Delphi too. var FunctionAddressList: Array of Integer; type TFunction = function(parameter: Integer): Integer; cdecl; function Function(parameter: Integer): Integer; var ExternFunction: TFunction; begin ExternFunction := TFunction(FunctionAddress...

How to tell if you're compiling on windows?

like is there a: #ifdef WINDOWS // do stuff #else // linux stuff #endif ?? ...

Why isn't string assignment optimised when the length is known to the compiler?

I was playing around today with some timing code and discovered that when asigning a string literal to std::string, that it was around 10% faster (with a short 12 char string, so likly even bigger difference for large strings) to do so with a literal of known length (using the sizeof operator) than not. (Only tested with the VC9 compiler...

How do I make this C++ object non-copyable?

See title. I have: class Foo { private: Foo(); public: static Foo* create(); } What need I do from here to make Foo un-copyable? Thanks! ...

[C++] [Windows] Net to Host Not Working

The value is 10240 or 2800 in hex. TOTAL_LENGTH is a unsigned short. 0028 in decimal is 40 which is what I am expecting (or is at least a reasonable value). Any ideas why I am getting a 0 instead of a 40? Thinking about reversing the bits myself but really don't want to. xD unsigned short total_length = ntohl(ipData->TOTAL_LENGTH); ...

IPP and DEV C++

Hi i use DEV C++ compiler in windows xp sp2 and recently i downloaded the IPP libraries. I installed successfully , i set up the compiler directories from option menu to IPP directories but when i try to compile an ITT program i get linker error for the ITT functions. Is there a solution? ...

C++ member function applied to object

hi I want to call member function by passing it as template parameter, without using boost is possible. Here is an example off what I tried to do, class object { void method(); } { object object_instance; ... apply<object:: method>(); ... template<class F> void apply() { F(object_instance); } // want to call object_instance.F() } t...

Good source to learn about the differences between ATI and NVIDIA in OpenGL rendering?

The more i learn about OpenGL, the more problems i find! All i need is a list of the most common problems between ATI/NVIDIA cards, with solutions. So where is this magical source? ...

Good tools for Multi-threaded C++ debugging on MacOSX?

Hi! I recently switched form ubuntu to MacOSX. I also recently started heavily using multi threading. What good addons/alternatives are there to g++ for debugging multi-threaded apps on MacOSX? In particular, I'm interested in tools that let me "poke" around classes/structs; to follow pointers, expand members, show the value of member...

Simple Win32 Trackbar

I have created a simple game using Win32 and gdi. I would like to have a track bar at the bottom that tracks a global variable. I'm just not sure how to add controls. How could I add a trackbar? I can imagine it would get created in the wm_create event. ...

Remove '\n.\n' C++

If i have a string as such "I am not here... \n..Hello\n.\n....Whats happening" I want to replace the above string so: "I am not here... \n..Hello\n. \n....Whats happening" ^ Space added Just a bit of a background on what im doing. Im using sendmail in C++ and \n.\n is End Of Message Equivalent of sen...

function template overloading

Hi, Can anybody summarize the idea of function template overloading? What matters, template parameter or function parameter? What about the return value? For example, given a function template template<typename X, typename Y> void func(X x, Y y) {}; what's the overloaded function template? 1) template<typename X> void func(X x, i...

No matching function error in Xcode 3

I am trying to compile a custom class in Xcode 3 and I keep getting a no matching function call error although the same custom class compiles fine under Windows. Obviously something is not right regarding the use of curly brackets and the XCode compiler. The compiler is choking at the first curly bracket { below: : ADataBrowser(inOwne...