1.2.5 Classes

Origin C supports many built-in classes, but also allows users to create their own.

Origin Defined Classes

Origin C comes with predefined classes for working with Origin's different data types and user interface objects. These classes will help you quickly write Origin C code to accomplish your tasks. This section will discuss the base classes to give you an overview of the capabilities these classes offer. See the next chapter, Predefined Classes, or the Origin C Wiki for more details and examples of Origin defined classes.

User Defined Classes

Origin C supports user-defined classes. A user-defined class allows Origin C programmers to create objects of their own type with methods (member functions) and data members.

The following code creates a class named Book with two methods, GetName and SetName.

class Book
	string GetName()
		return m_strName;

	void SetName(LPCSTR lpcszName)
		m_strName = lpcszName;
	string m_strName;

And below is a simple example using the class and method definitions above to declare an instance of the Book class, give it a name using SetName, and then output the name using GetName.

void test_class()
	Book OneBook; // Declare a Book object

	// Call public function to Set/Get name for the Book object

The above example is very simple. If you want to know more class features, for example, constructors and destructors, or virtual methods, please download this zip file, unzip and browse to the \Origin C Examples\Programming Guide\Extending Origin C subfolder to view the EasyLR.c, EasyLR.h and EasyFit.h files.