c++

VC++2008 project always "out of date"

In one Solution, I have two VC++ projects. Project A has linker inputs that are .obj files compiled by project B. Visual Studio (2008) always tells me that project A is "out of date," and prompts me to ask if I want to rebuild it, every time I want to run/debug/build/etc. Even immediately after building the entire Solution: I do a suc...

Inline code when counting data items (using templates)

There is a simple POD data type like struct Item { int value1; double value2; bool value3; } Now I would like to write different count functions like it could be done with the following code (or some std method): typedef bool Selector(const Item& i); int count(const vector<Item>& items, Selector f) { int sum = 0; BOOST_...

Is there anything that i can do in C but not in C++?

Possible Duplicate: Is there something that I can do in C but I cant do in C++ ? I am in a graduate level and I seen that C++ is derived from C with OOP added. I have a doubt that is there anything I can do in C but not in C++. ...

__attribute__((init_priority(X))) in GCC

I'm using __attribute__((init_priority(X))) in GCC like this: Type1 __attribute__ ((init_priority (101))) name1 = value1; Type2 __attribute__ ((init_priority (102))) name2 = value2; in different source files. Let's say file1.cpp and file2.cpp. If I use this in same library it works as expected, name1 is initialized before name2 but i...

Replacement for ViewBox in free for commercial use framework under Windows

Hello, I want to develop windows C/C++ program, but i need in it functionality like a Viewbox from .NET WPF. But i don't want buying Visual Studio platform because it has this control. Can anyone tell me something replacment for this? I want to do window, which after resizing, resizes its contents with good proportion (images buttons ...

Stick Window to Other Window

Hello, I want to develop Windows program who can stick into other window. I searching fastest-way to do this. I can get by WinAPI all information about target window and move my window into good location and after it Sniffing Windows Messages of target window to searching resize or move window and after this doing move my window again....

What is better in terms of memory allocation - subobject or a pointer to a separate object?

I have the following problem in a Visual C++ 9 program. There's a huge object that logically contains several subobjects. I can either store the subobjects inside the object or store pointers to subobjects allocated separately. The key point here is that there's always one instance of suboject of each type in one outer object - it is al...

sending email with smtp.

Hello. I try to do a program which sending emails. At the begining it works fine - I get 220(means "Hi"), then when I say "MAIL FROM:" it returns 250 (means OK) but then when I write "RCPT TO:" I get the 550 error and it writes "Relaying not allowed". why is google's smtp doesn't like it? My code: http://pastebin.com/wNA1Zp26 *by the w...

Why can't I do tupleVar.get(3) or .get<3>()?

I was going over C++0x. As i looked at tuple I saw this example. Why do I need to do get<3>(var)? Why can't I do var.get(index) or var.get<index>()? I prefer these to make code look and feel consistant. typedef tuple< int, double, long &, const char * > test_tuple ; long lengthy = 12 ; test_tuple proof( 18, 6.5, lengthy, "Ciao!" ) ; len...

WideCharToMultiByte problem

I have the lovely functions from my previous question, which work fine if I do this: wstring temp; wcin >> temp; string whatever( toUTF8(getSomeWString()) ); // store whatever, copy, but do not use it as UTF8 (see below) wcout << toUTF16(whatever) << endl; The original form is reproduced, but the in between form often contains extr...

C++: STL troubles with const class members.

It is an open ended question. Effective C++. Item 3. Use const whenever possible. Really? I would like to make anything which doesn't change during the objects lifetime const. But const comes with it own troubles. If a class has any const member, the compiler generated assignment operator is disabled. Without an assignment operator a cl...

Can you write a polymorphic class to disk and survive?

Firstly, I know that writing a class to disk is bad, but you should see some of our other code. D: My question is: can I write a polymorphic class to disk and then read it in later and not get undefined behaviour? I am going to guess not because of vtables (I think these are generated at runtime and unique to the object?) I.e. class A...

Qt Eclipse Integration and Custom Widget PlugIn

Does anyone know the correct procedure to compile a Custom Widget to be used under Eclipse Integration Plugin under Windows with MinGW? I tried the following steps, but I cannot see the widget in Widget Bar: Installed Qt 4.6.1 for Win32 (with MinGW) Installed Eclipse Helios 32bit (tried with Galileo too) Installed Qt Eclipse Integrato...

Is ther anyway to create a non-type template parameter for a class but not declare using <>?

My original code looks like this: class a{ ... char buff[10]; } and im attempting to make this change to the code: template <int N = 10> class a{ ... char buff[N]; } Is there any thing I can do to keep my existing code creating instances of class a like this: a test; instead of making the change to: a<> test; to get the defau...

volatile and multithreading?

In the following code: #include <pthread.h> #include <unistd.h> #include <stdio.h> pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int ready = 0; wait() { int i; do { usleep(1000); pthead_mutex_lock(&mutex); i = ready; pthread_mutex_unlock(&mutex); } while (i == 0); printf("Fin...

C++ why do I only get the last line?

Hi, This is the text of my program: #include <iostream> #include <string> #include <sstream> #include <fstream> using namespace std; int main(){ string line; ifstream inf("grid.txt"); while(!inf.eof()){ getline(inf, line); cout << line; } return 0; } (I'll be using sstream later) This is the cont...

Windows Application in C

Can anyone tell me how I can create a basic usable Windows application in C (I have a little idea about C++ also) ? ...

question about locale

please explain purpose of usage of locale in c++? i have read documents but dont uderstand please help ...

Memory structure of a function-only object?

Hi, Let's say we have a class that looks like this: class A { public: int FuncA( int x ); int FuncB( int y ); int a; int b; }; Now, I know that objects of this class will be laid out in memory with just the two ints. That is, if I make a vector of instances of class A, there will be two ints for...

Using QtMobility in QtCreator: Setup??

I am trying to set up a development environment to play around with developing Qt apps for Symbian devices. I have succesfully set up the environment and am able to create simple apps such as HelloWorld and get them to run on my device. I would now like to try using the QtMobility package, but I am struggling to get it to work in QtCre...