I have the following code and i dont understand why P4(3,7)is giving returnvalue true (1) , since here 7(ConTemp.XYCoord[1]) is bigger than 5 (ReCoordRo.XYCoord[1]), so i would like to know a way to monitor the boolean Rechteck1.contains(P4), watch windows doesnt give me that option, so how do i go about it ? Thx

#include <iostream>
#include <array>

 using namespace std;
    class Punkt {
        public: int XYCoord [2]={};
        void setupCoord (int x, int y){
            XYCoord[0]=x;
            XYCoord[1]=y;
        }
    };
    class Rechteck {
        public: Punkt ReCoordLu,ReCoordRo;

        double flaeche(double x, double y){
            double xy=x*y;
            return xy;
            }
        bool contains ( Punkt &p){
            Punkt *ConTemp1=&p;
            Punkt ConTemp ;
            ConTemp = *ConTemp1;

            if (ConTemp.XYCoord[0]>=ReCoordLu.XYCoord[0]&&ConTemp.XYCoord[1]<=ReCoordRo.XYCoord[1]){
                return true;}
            else{
                return false;}
                };
        bool contains (Rechteck &){
            if (1){
                return true;}
            else
                return false;
            }
        };
int main()
{/* Rechteck sharedRectangle (Rechteck a , Rechteck b){
            Rechteck c;
            return Rechteck c;
            } */

        Punkt P1,P2,P3,P4;
        P1.setupCoord(1,1);
        P2.setupCoord(5,5);
        P3.setupCoord(3,3);
        P4.setupCoord(3,7);
        Rechteck Rechteck1;
        Rechteck1.ReCoordLu.setupCoord(3,3);
        Rechteck1.ReCoordRo.setupCoord(9,9);
Rechteck1.contains(P4) 

        cout<<"hello"<<P2.XYCoord[0]<<Rechteck1.ReCoordLu.XYCoord[0]
        <<Rechteck1.flaeche(5,5)<<Rechteck1.contains(P4) ;

        return 0;};

Problem solved !It actually works looked like i just mistook Rechteck1.ReCoordLu.setupCoord(3,3)with
Rechteck1.ReCoordRo.setupCoord(9,9)

What IDE are you using?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.