c++

Why do I need an *.obj file when statically linking?

I'm not sure why is this. I'm distributing a static *.lib across multiple projects, but this static lib generates many *.obj files. Seems like I need to distribute also those *.obj files with the *.lib. Otherwise, I get this error: 1>LINK : fatal error LNK1181: cannot open input file 'nsglCore.obj' Why is this? Is there a way to inclu...

Why doesn't this return type work? (C++)

When I try to use my iterator class template<class T> class list { public: class iterator; }; template<class T> class list<T>::iterator { //stuff }; as a return type in an operator overloading, template<class T> class list<T>::iterator { public: iterator& operator++(); protected: list* lstptr; }; template<class T> iterator& list<T>...

What would cause a parent window to not know that it had a child dialog?

In my native windows mobile app I've got a window that creates a dialog. Lets say my window handle is hMainWnd. I create the dialog using DialogBoxParam() and passing in hMainWnd as the dialog's parent: DialogBoxParam(_,_,hMainWnd,_,_); Let's say the dialog's handle is hDlgWnd. From within the dialog, GetParent() returns hMainWnd ...

What does the '%lt' mean in C++? (NOT modulus, I know what that does)

I once saw this line of code: std::cout %lt;%lt; "Hello world!" %lt;%lt; std:: endl; And am wondering what %lt;%lt; means. ...

C++ CRTP issues, MSVC error C2039

MSVC 2008 won't compile this code: template <class Derived> struct B { typename Derived::type t; }; struct D : B<D> { typedef int type; }; void main() { D d; } The error I get is "error C2039: 'type' : is not a member of 'D'". Any ideas? ...

Best book for a "good" functional programmer to learn C++ thoroughly?

Hello all. I'm a "good" programmer. I know Haskell, OCaml, and other functional languages very well. I know also Smalltalk, Objective-C, and other OO languages. I spend my time on LtU, I know a fair amount about programming language theory and compiler design, and above all, I'm, ahem, incredibly brilliant. That said, I'm also hungry, a...

Calling swprint from a separate lib fails

Hi all I am facing a strange problem. I am using sprintf or swprintf according to the build defines with or without unicode. I have wrapped these functions in my own function like this: int mysprintf( MCHAR* str,size_t size, const MCHAR* format, ... ) { #ifdef MYUNICODE return swprintf( str, size, format); #else return snprintf...

How can I increase the stack memory?

Duplicate of http://stackoverflow.com/questions/743545/how-to-allow-more-memory-and-avoid-stack-overflow-on-lots-of-recursion I'm writing a branch and bound algorithm which has at least 10000 levels by a recursive function,but it doesn't work due to a stack overflow error. here is a simple instance of my program in C++: void f(int k) {...

Partition sort programming problem

I need an algorithm to select the kth largest or smallest value. The values will be ints. My instructor told me to use a modified partition algorithm to find the kth largest or smallest value. Any thoughts? ...

C++ std::vector of pointers deletion and segmentation faults

Hello all, I have a vector of pointers to a class. I need to call their destructors and free their memory. Since they are vector of pointers vector.clear() does not do the job.So I went on to do it manually like so : void Population::clearPool(std::vector<Chromosome*> a,int size) { Chromosome* c; for(int j = 0 ;j < size-1;j++) ...

Developer notebook configuration

I want to buy a brand new notebook for out-of-the-office work. I mainly develop using VC++ (vs03) and c# (vs08) on large projects (10 gb builds). At office I've a quad core xeon with 10.000 rpm disk. What hardware, according to your experience, is the best for this kind of work in terms of price / performances / weight? ...

Design Pattern for optional functions?

I have a basic class that derived subclasses inherit from, it carries the basic functions that should be the same across all derived classes: class Basic { public: Run() { int input = something->getsomething(); switch(input) { /* Basic functionality */ case 1: doA(); break; case 2: ...

Should I prefer pointers or references in member data?

This is a simplified example to illustrate the question: class A {}; class B { B(A& a) : a(a) {} A& a; }; class C { C() : b(a) {} A a; B b; }; So B is responsible for updating a part of C. I ran the code through lint and it whinged about the reference member: lint#1725. This talks about taking care over defaul...

cannot convert from 'WCHAR' to 'WCHAR [260]'

Hi, I am trying to modify the amcap, an application from Windows SDK's example to capture video from UVC webcam having resolution 1600x1200px. I am trying to hardcode some variables here like filename, default resolution, type of format etc. WCHAR wszCaptureFile[260]; gcap.wszCaptureFile = (WCHAR)"Capture.avi\0" //modified gettn...

Character encoding confusion!

Hi, Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and ANSI. After doing some research I have some idea but it would be really useful if someone could explain exactly the difference between them (including the byte representation of a typical character from each). I quess my question boils down t...

regarding encryption method

hi, i am using encrypt function of cryptography api(fun declared as virtual) //fun declaration TBool EncryptL(const TDesC8 &aInput, TDes8 &aOutput); //function calling TBuf8<10> text; TBuf8<10> cipher; text.Copy(_L("Hello")); iEncryptor.EncryptL(text,cipher); it shows error expression syntax error //fun definition TBool CRSAAlgo::Enc...

C++: optimizing member variable order?

I was reading a blog post by a game coder for Introversion and he is busily trying to squeeze every CPU tick he can out of the code. One trick he mentions off-hand is to "re-order the member variables of a class into most used and least used." I'm not familiar with C++, nor with how it compiles, but I was wondering if This sta...

c++ win32 popup animation

Hello, I am creating an application that uses popups. However, I would like to animate this popup (a win32 window, a HWND), for example having it slowly extend from the bottom of my screen, moving upwards. Should I make a few dozens of calls to the SetWindowPos function with a small pause in between, or is there a better way to do this, ...

How do I extract the angle of rotation from a QTransform?

I have a QTransform object and would like to know the angle in degrees that the object is rotated by, however there is no clear example of how to do this: http://doc.trolltech.com/4.4/qtransform.html#basic-matrix-operations Setting it is easy, getting it back out again is hard. ...

"Deprecated" notation for Sun's C++ compiler?

Does the Sun compiler have a notation to mark functions as deprecated, like GCC's __attribute__ ((deprecated)) or MSVC's __declspec(deprecated)? ...