multidimensional array initializer costruct class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scarbo
    New Member
    • Sep 2006
    • 3

    #1

    multidimensional array initializer costruct class

    Hello to all. I have a problem for initialize an Array multidimensiona l, therefore I have seen from the forum, but it does not work correctly. An Array of 1024 allocations for 2 channels would serve me (left and rigth). that is:

    double A [1024] [2];

    myClass ()
    {
    public:
    myClass()
    {
    s = 1024;

    A = new double*[s];

    for (int i=0;i<s;i++)
    A[i]=new double[2];
    }

    private:
    unsigned long s;
    double **A;
    }

    Sbaglio qualche cosa?
    Grazie ciao.
  • scarbo
    New Member
    • Sep 2006
    • 3

    #2
    multidimensiona l array initializer costruct class

    Hello to all. I have a problem for initialize an Array multidimensiona l, therefore I have seen from the forum, but it does not work correctly. An Array of 1024 allocations for 2 channels would serve me (left and rigth). that is:

    double A [1024] [2];

    myClass ()
    {
    public:
    myClass()
    {
    s = 1024;
    A = new double*[s];
    for (int i=0;i<s;i++)
    A[i]=new double[2];
    }
    private:
    unsigned long s;
    double **A;
    }

    Mistake some thing? Thanks hello.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Basically

      Code:
      myClass ()
      {
      // class definition
      }
      should be


      Code:
      class myClass
      {
      // class definition
      };

      Also it would be better if the type of i matched the type of s (i.e. unsigned long).

      And Finally please don't double post.

      Comment

      • scarbo
        New Member
        • Sep 2006
        • 3

        #4
        yes, is the banal forgetfulness is one. But the problem remains.

        Comment

        • ltgbau
          New Member
          • Sep 2006
          • 41

          #5
          use
          class myClass
          {

          instead
          myClass ()
          {

          Comment

          Working...