Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    IsEqual not defined

    Cinema 4D SDK
    r20 c++
    2
    3
    570
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C4DSC
      C4DS
      last edited by C4DS

      I get a compiler error, and can't seem to wrap my head around the actual problem
      Say I have the following code (reduced to a dummy minimum for purpose of demonstration):

      
      #include "c4d.h"
      
      class Int32Pair
      {
      public:
      	Int32Pair() : a(0), b(0) {}
      	Int32Pair(const Int32& _a, const Int32& _b) : a(_a), b(_b) {}
      	virtual ~Int32Pair() {}
      private:
      	Int32 a;
      	Int32 b;
      };
      
      class Test
      {
      public:
      	Test()
      	{
      		maxon::BaseArray<Int32Pair> somedata;
      		if (somedata == mPairArray)
      		{
      			// do something
      		}
      	}
      
      	~Test() {}
      
      private:
      	maxon::BaseArray<Int32Pair> mPairArray;
      };
      

      Basically, I have two arrays of Int32Pair which I want to compare, but compiler gives me a

      error C2338: IsEqual not defined.
      

      Which I have narrowed done as being caused by the line

      if (somedata == mPairArray)
      

      Where should this IsEqualbe defined?

      Inspired by the SortedArray example I tried adding an IsEqual into the Int32Pair class as:

      static maxon::Bool IsEqual(const Int32Pair& p1, const Int32Pair& p2) { return (p1.a == p2.a) && (p1.b == p2.b); }
      

      But compiler still complains about IsEqual not being defined.
      As such, I am guessing it's the BaseArray which needs to be defined with a compare method. But how? Have tried looking into the BaseArray manual, but failed to find any answer.

      I would appreciate an example showing how it needs to be done. Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hello,

        you have to define the operator == in your class Int32pair.
        For this you have a macro that help, it will implement both == and != operator.

        class Int32Pair
        {
        public:
        	Int32Pair() : a(0), b(0) {}
        	Int32Pair(const Int32& _a, const Int32& _b) : a(_a), b(_b) {}
        	virtual ~Int32Pair() {}
        	
        	MAXON_OPERATOR_EQUALITY(Int32Pair, a, b);
        
        
        private:
        	Int32 a;
        	Int32 b;
        
        
        };
        

        Let me know if it solve the problem πŸ™‚

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • C4DSC
          C4DS
          last edited by

          @m_magalhaes said in IsEqual not defined:

          MAXON_OPERATOR_EQUALITY(Int32Pair, a, b);

          Thanks, didn't know about the MAXON_OPERATOR_EQUALITY. Very handy indeed.

          However, I had already tried providing an equality operator in my Int32Pair class, as such:

          Bool operator == (const Int32Pair& other) { return (a == other.a) && (b == other.b); }
          

          But that still resulted in the "IsEqual not defined" compiler error.
          The macro, however, is working fine.

          Looking further at my implementation of operator==, I now notice I didn't declare it as a const method. Adding the const does get rid of the compiler error. Oh boy! Overlooked a minor "typo", with major consequences.

          Again, thanks for the macro.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post