Skip to main content
Glama
Calculator.cpp1.4 kB
// C++ test file #include <iostream> #include <memory> namespace Math { template<typename T> class Calculator { private: T result; public: Calculator() : result(T{}) {} static T calculateSum(T a, T b) { return a + b; } Calculator& add(T value) { result += value; return *this; } Calculator& multiply(T value) { result *= value; return *this; } T getResult() const { return result; } }; enum class Operation { ADD, SUBTRACT, MULTIPLY, DIVIDE }; template<typename T> T applyOperation(Operation op, T a, T b) { switch (op) { case Operation::ADD: return a + b; case Operation::SUBTRACT: return a - b; case Operation::MULTIPLY: return a * b; case Operation::DIVIDE: return a / b; default: return T{}; } } } struct Point { double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} double distance() const { return std::sqrt(x*x + y*y); } }; int main() { Math::Calculator<double> calc; auto result = calc.add(10.0).multiply(2.0).getResult(); std::cout << "Result: " << result << std::endl; return 0; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/FarhanAliRaza/claude-context-local'

If you have feedback or need assistance with the MCP directory API, please join our Discord server