c++

vector of objects

I tried to add objects to the "content" vector, and use show() on all of them. But the objects that are children (A, B) of "Base" behave like they were of "Base" type, what is not my intention. As it seems, I tried to use virtual functions but it doesn't work. I hope that the code will speak for itself. class Base { public: ...

Is it possible to refresh two lines of text at once using something like a CR? (C++)

Right now, I have a console application I'm working on, which is supposed to display and update information to the console at a given interval. The problem I'm having is that with a carriage return, I can only update one line of text at a time. If I use a newline, the old line can no longer be updated using a carriage return. What can I...

Array of pointers member, is it initialized?

If I have a class A { private: Widget* widgets[5]; }; Is it guaranteed that all pointers are NULL, or do I need to initialize them in the constructor? Is it true for all compilers? Thanks. ...

Determining type of pcap file.

How can I determine if a saved .pcap file contains an ERF (Extensible Record Format) header? pcap_open_offline() doesn't provide this information. I'm running into issues where some captures I open have the 16-byte header, and some don't, and I can't find any documentation online in how to determine the format. ...

What will happen to namespace tr1 when c++ xx is approved?

I'm writing some stuff using the tr1 namespace in VS2008. What will happen when C++xx becomes ratified? Has this happened before with other C++ revisions? Will the tr1 stuff still work or will I have to change all of my include? I realize that I'm making the very large assumption that this ratification will someday occur. I know that mos...

OpenGL: Enabling multisampling draws messed up edges for polygons at high zoom levels

When im using this following code: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 6); and then i enable multisampling, i notice that my program no longer cares about the max mip level. Edit: It renders the last miplevels as well, that is the problem, i dont want them being rendered. Edit3: I tested and confirmed that it doesnt...

Why is my call to TransmitFile performing poorly compared to other methods?

First, a bit of background -- I am writing a basic FTP server for a personal project. I'm currently working on retrieving files. My current implementation looks like this: HANDLE hFile = CreateFile("file.tar.gz", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); TransmitFile(sd, hFile, fileSize, 65536, NU...

iTunes COM interface, get the content of the search box

Is there any way to obtain a reference to the iTunes search box, and read the current content out of it? Either in C# or C++. I am using the iTunes 1.12 Type Library. ...

Why the std::swap of Bits in a std::bitset instance doesn't work?

In the following example i expected the swap of the bits. Instead the second bit becomes overwritten, but why and how could i achieve the expected behavior? #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { bitset<2> test(string("10")); cout << test; // Prints "10" swap(test[0], t...

C++ explicit constructors and iterators

Consider the following code: #include <vector> struct A { explicit A(int i_) : i(i_) {} int i; }; int main() { std::vector<int> ints; std::vector<A> As(ints.begin(), ints.end()); } Should the above compile? My feeling is that it should not, due to the constructor being marked explicit. Microsoft Visual C++ agrees, g...

Finding boost::shared_ptr cyclic references

Is there any tips/tricks for finding cyclic references of shared_ptr's? This is an exmaple of what I'm trying to find - unfortunately I can't seem to find the loop in my code. struct A { boost::shared_ptr<C> anC; }; struct B { boost::shared_ptr<A> anA; }; struct C { boost::shared_ptr<B> anB; }; ...

How to build a boost dependent project using regular makefiles?

I'm working on a c++ project, and we recently needed to include a small part of boost in it. The boost part is really minimal (Boost::Python), thus, using bjam to build everything looks like an overkill (besides, everyone working on the project feels comfortable with make, and has no knowloedge of jam). I made quite some tests already, ...

Send email through Gmail using c++, Linux

Hello. I would like to send an email via Gmail with C++ as one would send an email from a desktop mail client configured to use a Gmail account. I have been looking at a few like jwSMTP and popen+sendmail, but those look like they only work if the host is a mail server. I know this task is a well-tread path in Python, but have never tr...

nginx not forwarding POST to @fallback

Hello. I wrote a high-performance HTTP event server in C++ and I want to make it work flawlessly with nginx and PHP-FPM (fastcgi). This is a snippet of my nginx configuration. location ~ \.eve$ { gzip off; proxy_redirect off; proxy_buffering off; proxy_pass http://127.0.0.1:9001; proxy_interce...

In C++ what causes an assignment to evaluate as true or false when used in a control structure?

So can someone help me grasp all the (or most of the relevant) situations of an assignment inside something like an if(...) or while(...), etc? What I mean is like: if(a = b) or while(a = &c) { } etc... When will it evaluate as true, and when will it evaluate as false? Does this change at all depending on the types used in the as...

[C++] MSVC and FreeGlut Compiler Error

Receiving alot of these messages when compiling which is making compiling a simple program very time consuming. freeglut_static.lib(freeglut_callbacks.obj) : warning LNK4204: 'z:\CST328\Lab1\block\Release\vc90.pdb' is missing debugging information for referencing module; linking object as if no debug info 1>freeglut_static.lib(freeglut_...

Design alternative? Composition and construction

So I'm using composition to bring together a collection of objects, all of which are derived from a base class, lets say Component. E.g: class Component { public: Component(); ... private: int m_address; ... }; class SpecializedComponent: public Component { public: SpecializedComponent() ... //and so on }; class Specialize...

When using variable length argument lists (...), can you do anything besides step forward through va_list?

If each invocation of va_arg modifies the object declared with va_list so that the object points to the next argument in the list, is there any way to step back so that it points to the previous one, jump back to the first one, jump to the end? Go three quarters of the way though the list and then... you get the idea. Or is it a once pas...

where to get the source code for standard c++ library

is it possible to get the source code for standard c++ library? ...

Is there any way I can find how many objects are instanciated from stack and how many objects from Heap. I dont wish to have the restrictions of scoping in objects from Stack.

Is there any way I can find how many objects are instanciated from stack and how many objects from Heap. I dont wish to have the restrictions of scoping in objects from Stack. If i use a static counter in constructor and destructor, it will be called in both the cases(object from stack and heap). One way is to exploit the idea are objec...