POV-Ray : Newsgroups : povray.off-topic : C++ question : Re: C++ question Server Time
28 Jul 2024 16:24:18 EDT (-0400)
  Re: C++ question  
From: Warp
Date: 3 Oct 2013 15:41:58
Message: <524dc886@news.povray.org>
Anthony D. Baye <Sha### [at] spamnomorehotmailcom> wrote:
> I also tried declaring it as a class function:

This works just fine:

//----------------------------------------------------------------------
#include <iostream>

namespace geometry
{
    class A
    {
     public:
        int value() const { return 5; }
    };

    inline std::ostream& operator<<(std::ostream& os, const A& obj)
    {
        os << obj.value();
        return os;
    }
}

int main()
{
    geometry::A a;
    std::cout << a << std::endl;
}
//----------------------------------------------------------------------


-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.