Class

Class
Classes are the primary component in object-oriented programming. They allow the programmer to create custom objects that can be used and extended to create interchangeable modules for your program. A class can have static variables that share the same value across all instances. They can also add public, private, and protected modifiers to data and methods. Classes can also take advantage of templates/generics. The modifiers on the methods and data in the class changes the elements visibility from different perspectives. A public modifier makes the object or method visible to all, a private modifier makes it visible only from within the class methods, and a protected modifier makes it visible only to the class and children of the class.

In Java
code format="java" public class Main{//this is a class class Student{ private int id; //private data private String name; public Student(String name, int id){ this.name = name; this.id = id; }       public String toString{ return id + ": " + name; }   }    public static void main(String[] args){ Student tyler = new Student("Tyler Brazill", 55555); System.out.println(tyler.toString); } } code

In C++
Notice the similarities between the struct example. code format="cpp"
 * 1) include

class student{ private: int id; //data char *name; public: student(char *name, int id); //constructor ~student; //destructor void print; //method };//don't forget this semicolon(I think)

student::student(char *name, int id){ this->name = name; this->id = id; } student::~student{ delete[] name; } void student::print{ printf("%d: %s\n", id, name); }

int main{ student tyler("Tyler Brazill", 55555); //initialization with constructor tyler.print; //call to the method

return 0; } code