By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

multidimensional array initializer costruct class

P: 3
Hello to all. I have a problem for initialize an Array multidimensional, 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.
Sep 25 '06 #1
Share this Question
Share on Google+
4 Replies


P: 3
Hello to all. I have a problem for initialize an Array multidimensional, 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.
Sep 25 '06 #2

Banfa
Expert Mod 5K+
P: 8,916
Basically

Expand|Select|Wrap|Line Numbers
  1. myClass ()
  2. {
  3. // class definition
  4. }
  5.  
should be


Expand|Select|Wrap|Line Numbers
  1. class myClass
  2. {
  3. // class definition
  4. };
  5.  

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.
Sep 25 '06 #3

P: 3
yes, is the banal forgetfulness is one. But the problem remains.
Sep 26 '06 #4

P: 41
use
class myClass
{

instead
myClass ()
{
Sep 29 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.