Very Simple Class

Header file
//******************************
//******************************
//********** MY CLASS **********
//******************************
//******************************
class MyClassName
{
public:
    unsigned char MyClassByte;
    unsigned int MyClassInt;

	//***** CONSTRUCTOR *****
	MyClassName()
	{
		this->MyClassByte = 0;
		this->MyClassInt = 0;
	}
	
	//***** DECONSTRUCTOR *****
	~MyClassName() {};
};
Using it
	MyClassName MyClassName1;
	MyClassName1.MyClassByte = 24;
	MyClassName1.MyClassInt = 25;

//If you want to pass it to a function:
	void my_function (MyClassName *MyClassName1)
	{
		MyClassName1->MyClassByte = 24;
		MyClassName1->MyClassInt = 25;
	}

More Complex Class

Header file
//******************************
//******************************
//********** MY CLASS **********
//******************************
//******************************
class MyClassName
{
public:
    MyClassName();
    MyClassName(std::string MyClassSetupString, unsigned char MyClassByte_set, unsigned int MyClassInt_set);
    ~MyClassName();
    
	//int MyClassPublicFunction(void);

private:
    unsigned char MyClassByte;
    unsigned int MyClassInt;

    int MyClassPrivateFunction(std::string SetupString);
};
CPP File

//*****************************************
//*****************************************
//********** DEFAULT CONSTRUCTOR **********
//*****************************************
//*****************************************
MyClassName::MyClassName()
{
	this->MyClassByte = 0;
	this->MyClassInt = 0;
	this->MyClassPrivateFunction(std::string("Hello"));
}

//********************************************
//********************************************
//********** OVERLOADED CONSTRUCTOR **********
//********************************************
//********************************************
MyClassName::MyClassName(std::string MyClassSetupString, unsigned char MyClassByte_set, unsigned int MyClassInt_set)
{
	this->MyClassByte = MyClassByte_set;
	this->MyClassInt = MyClassInt_set;

	this->MyClassPrivateFunction(MyClassSetupString);
}

//***********************************
//***********************************
//********** DECONSTRUCTOR **********
//***********************************
//***********************************
MyClassName::~MyClassName()
{
    
}

//********************************
//********************************
//********** A FUNCTION **********
//********************************
//********************************
int MyClassName::MyClassPrivateFunction(std::string SetupString)
{
	/*
    if (something)
	{
        perror("Could not do something");
        exit(1);
    }
	*/

    return(0);
}
Using it
	MyClassName MyClassName1;
	MyClassName1.MyClassPrivateFunction("Test");
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *