Menu

how to initialize a object table ?

2002-11-14
2012-09-26
  • Nobody/Anonymous

    i have the following class in C++:

    class point
    {int x,y;
    public: point(int abs=0,int ord=0.0)
              {x=abs;y=ord;}
    };

    how can i initialize the values x, y of a "point" table, in a main program ?

    void main()
    {int i;
    point curve[5]={7,4,2,3,5}; // this instruction only initialize "x" values of the table "curve"; how can i do for "y" values ?
    }

    thanks.

     
    • Nobody/Anonymous

      Use a constructor

      class Bhad
      {
        public:
          // Constructor
          Bhad(double mem1 = 1.0, double mem2 = 1.0, double mem3 = 1.0);

          // Function
          double Bhadn();

        private:
          double mem 1;
          double mem 2;
          double mem 3;
      };

      #endif

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.