Files
strangecpp/cpplinker/10_debug_linker/math_lib.hpp

26 lines
694 B
C++

#pragma once
namespace Math {
// Free functions — each becomes a mangled symbol, e.g.
// Math::sqrt(double) → _ZN4Math4sqrtEd
// Math::square(double) → _ZN4Math6squareEd
// Math::cube(double) → _ZN4Math4cubeEd
double sqrt(double x);
double square(double x);
double cube(double x);
// Class — member functions add even richer mangling
class Vector2D {
public:
double x, y;
Vector2D(double x, double y);
double length() const;
Vector2D add(const Vector2D& other) const;
Vector2D scale(double factor) const;
double dot(const Vector2D& other) const;
};
} // namespace Math