Cant read class variable.
class.cpp
Code:
// testing.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "class.h"
int main(int argc, char* argv[])
{
char buffer[50];
myclass_t myclass_h;
myclass_h.set( );
sprintf( buffer, "%i", myclass_h.read_value() );
printf ( buffer );
myclass_h.unset( );
sprintf( buffer, "%i", myclass_h.read_value() );
printf ( buffer );
return 0;
}
int myclass_t::read_value ( void ) {
int value;
value = myclass_t::value;
return value;
}
void myclass_t::set ( void ) {
myclass_t myclass_h;
myclass_h.value = 1;
}
void myclass_t::unset ( void ) {
myclass_t myclass_h;
myclass_h.value = 0;
}
class.h
Code:
class myclass_t {
public:
void set ( void );
void unset ( void );
int read_value ( void );
private:
int value;
};
It should return 1 and 0. Keeps returning -858993460
Any help is much appreciated.