An instance to call non-static methods from static

I found the problem here in my code but I don't understand why it works like this. I'm trying to implement static instance to call non-static methods from static. I really need this for not well structured modules of SDK I'm using (Marmalade).

I get Marmalade's error that i'm trying to delete the object which is seems to be using at time. But if I change the line: instance.http = new CIwHTTP(); to this line: http = new CIwHTTP(); the error dissapears.

But why does it work like this? I thought the instance - it's the reference to my class like a "this" variable. Why there's so much difference here? I thought there is no any difference here between: "http." and "instance.http." but how can I do exactly the "this" reference to this class to use it inside static methods?

===[ HTTP.h ]===
#ifndef HTTP_H
#define HTTP_H
#include <s3e.h>
#include "IwHTTP.h"
class HTTP {
    CIwHTTP *http;

===[ HTTP.cpp ]===
#include "HTTP.h"
static HTTP instance;
char* result = NULL;
    instance.http = new CIwHTTP();
    if ( http ) {
        delete http;
    s3eFree( result );


Don't put the "instance." in the HTTP constructor. Otherwise you can never have more than one instance.

Need Your Help

tellg() function give wrong size of file?

c++ file ifstream

I did a sample project to read a file into a buffer.

Keeping model records and associated directories in sync (with tests)

ruby-on-rails activerecord rspec ruby-on-rails-3.2 filesystems

In my app I create a directory when I create my theme record. This is to store file assets related to the theme. I've always struggled with how to keep the existence of the directory in sync with the