xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a class and its object in C++
C++ Online Editor
Execute Code
More C++ Sample Code
#include <iostream> #include <string> using namespace std; // use std namespace to avoid std:: before cout // This is a class class Person { public: string Name; int Age; }; int main() { Person personObj; // personObj is an object of the Person class personObj.Name = "John"; // Assign value to the Name property personObj.Age = 25; // Assign value to the Age property cout << personObj.Name << " is " << personObj.Age << " years old." << endl; // Print the result return 0; }