c++

Any suggestions on where to learn C online in preparation of learning Objective-C

I've been programming PHP & mySQL for about 8 years now. I understand and make use of modern software architectures and OOP in my projects on a daily basis. I decided I want to learn something new. I finally decided yesterday that I want to learn C and eventually Objective-C so I can begin creating Mac / iOS applications. (Would you rec...

C++ Copy Objects from a file to a Array

Hi need to copy the written objects in a file to copy to a array But following code gives me a Error T Obj T arr[20]; while(file.read((char*)&Obj,sizeof(Obj))){ int i=0; i++ arr[i]==Obj; } Error C2678: binary '==' : no operator found which takes a left-hand operand of type ...

database table - data structure design c++

hi, this may be a dumb question or asked many times, i searched for it but did not find a proper answer. What is exactly going on when we type on SQL engine "Create table xxxx" how to implement this one in c++, i mean how it creates a variable dynamicalyy "xxxx" and store the data in it. If i queried "select * from xxxx" how it go to ...

C++ for_each() and the function pointer

I am try to make the myFunction give me a sum of the values in the array, but I know I can not use a return value, and when I run my program with the code as so all I get is a print out of the values and no sum why is that? void myFunction (int i) { int total = 0; total += i; cout << total; } int main() { int array[] = { 1, 2, 3, 4, 5...

detect obsolete and incorrect function prototypes with autoconf

I maintain an open source program that builds with autoconf. Right now I'm having a problem with some of my users. They are using a pre-distributed VM from an organization that has an incorrect prototype for strchr in it. Their prototype is: char *strchr(char *,int c); when of course we know it should be: char *strchr(const char *s...

Visual Studio incorrectly marking inactive code blocks when using `#ifdef`

My project has a bunch of #ifdefs. The macros used by these #ifdefs are usually passed through the command line using the '/D' option to get different build configurations. Visual studio incorrectly assumes that these macros are not defined and greys out the code blocks present inside these #ifdefs. The problem is not syntax highlighting...

Class Members Over Exports

When Using DLLs or Code-injecting to be Specific this is an example class only intended for explaining class test { int newint1; char newchararray[512]; void (*newfunction1)( int newarg1 ); int newfunction2( bool newarg1, char newarg2 ) { return newint1; } } mynewclass1; that covers most common elemen...

How to efficiently implement an immutable graph of heterogenous immutable objects in C++?

I am writing a programming language text parser, out of curiosity. Say i want to define an immutable (at runtime) graph of tokens as vertices/nodes. These are naturally of different type - some tokens are keywords, some are identifiers, etc. However they all share the common trait where each token in the graph points to another. This pro...

How to fullscreen a QGLWidget?

I am new to OpenGL and Qt, and I am learning both simultaneously(3 days already:). I couple of years ago I did some exmerimenting with DirectX and I clearly remember that it was possible to make a full-screen window there. By full-screen I mean really full-screen, even without the top part where you have the close fullscreen and minimize...

ASSERTS during the termination of an MFC application

If an ASSERT fires once ExitInstance() has entered, any ASSERT will, I assume, throw a structured exception, thus skipping the rest of the code in ExitInstance(). Can anyone shed a little light on this? ...

Deleting C++ pointers to an object

I thought that the delete command would free up memory I allocated. Can someone explain why it seems I still have the memory in use after delete? class Test { public: int time; }; int main() { Test *e; e = new Test; e->time = 1; cout << e->time << endl; delete e; e->time = 2; cout << e->time << endl;...

Moving compressed strings between C++ and PHP with zlib

I'm working on a project where a Windows web server running PHP is communicating over a very slow connection with a back end Linux server running an application written in C++. Because the connection between the two machines is so slow, I'd like to compress the traffic moving between them. I've gotten to where I can compress a string, ...

std::map with typedef type in it?

Is it a good idea to do the following in C++: typedef std::map<std::string, boost::any> MyVals; // Is the following typedef'd type inside a map a good idea? typedef std::map<std::string, MyVals> TagValues; These maps will be used a lot for sequential insertion and removal. ...

Float increments precision problems with UI

Here is my problem, I have several parameters that I need to increment by 0.1. But my UI only renders x.x , x.xx, x.xxx for floats so since 0.1f is not really 0.1 but something like 0.10000000149011612 on the long run my ui will render -0.00 and that doesn't make much sense. How to prevent that for all the possible cases of UI. Thank y...

Getting started with client-server networking

I'm a good programmer, but I have zero network experience. Basically, I'd like to get into client-server networking. For example, I'd like to try getting a server process going which allows clients to connect over the internet and send pings to all of the other connected clients. Then maybe I'll try developing a simple chat client, or s...

Function template as a parameter to a class template

<> - read this as a template; I can do this: void f() {} //Here I'm declaring a fnc as a <> param template<void (*fnc)()> struct Factor { }; int main() { Factor<f> fac; return 0; } but I cannot do this: #include <sstream> template<class R, class T> R make_(T first, T second) { std::stringstream interpreter; R resul...

Trouble implementing collision in a breakout clone.

For this program, I've been using the OpenGL-based reni2D library in Visual C++ 2008 Express Edition. The said library is on this webpage: http://www.involuntaryexercise.com/apps/reni2D.zip The problem I get happens when trying to make a brick from the sprite structure. I've been using an array of bricks, but at the moment have restrict...

SystemC Seg Fault on sc_core::sc_in<bool>::read()

Hello, I am having a repeating seg fault while using SystemC. During initialization I set a value to 0. During operation of a testbench I am setting this value to 1 in a module (proc). This is a sc_signal variable that is attached to a port of another module imem. The input port is of type sc_in. In theory, this assignment should c...

Passing HRESULT as a string on command line

I have a need to pass in an HRESULT value to a program as a command line argument. I had intended to do so by passing the hex value, e.g.: >receiver.exe 0x80048836 I'm trying to convert this string representation back into an HRESULT using wcstol, eg: HRESULT hr = wcstol(argv[2], NULL, 16); However, the value of the original HRESUL...

Call a non-const member function from a const member function

I would like to know if its possible to call a non-const member function from a const member function. In the example below First gives a compiler error. I understand why it gives an error, I would like to know if there is a way to work around it. class Foo { const int& First() const { return Second(); } int& Secon...