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 method in a class in C++
C++ Online Editor
Execute Code
More C++ Sample Code
#include <iostream> using namespace std; // use std namespace to avoid std:: before cout // This is a class class Math { public: // This is a function int AddNumber(int x, int y) { return x + y; } }; int main() { Math mathObj; // Object of the Math class // Calling the function and assigning the return value to sumVariable int sumVariable = mathObj.AddNumber(10, 20); cout << "The sum of 10 and 20 is " << sumVariable << "." << endl; return 0; }