Error when calling a method of dynamic array

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2007
Posts: 62
Reputation: kako13 is an unknown quantity at this point 
Solved Threads: 1
kako13's Avatar
kako13 kako13 is offline Offline
Junior Poster in Training

Error when calling a method of dynamic array

 
0
  #1
Feb 8th, 2008
Hi, I'm getting this error:
Asig 2.cpp In function `void ManiMatrix()': 31
Asig 2.cpp expected primary-expression before "int"
Asig 2\Makefile.win [Build Error] ["Asig 2.o"] Error 1

Here is how I'm calling it from main: customMatrix.checkIfMagic();
Prototype in the class: void checkIfMagic(int**);
void matrix::checkIfMagic(int **arrayOfArray)
{// function began


} // function end
Any suggestion will be appreciated.
Last edited by kako13; Feb 8th, 2008 at 9:41 pm.
Computer Science Student @ www.upra.edu
Camuy, PR USA
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Error when calling a method of dynamic array

 
0
  #2
Feb 8th, 2008
Originally Posted by kako13 View Post
Asig 2.cpp In function `void ManiMatrix()': 31

I don't see anything wrong with checkIfMagic . But what is this function void ManiMatrix() in the first warning? Also make sure that Mani is not a misspelling for Main .
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 62
Reputation: kako13 is an unknown quantity at this point 
Solved Threads: 1
kako13's Avatar
kako13 kako13 is offline Offline
Junior Poster in Training

Re: Error when calling a method of dynamic array

 
0
  #3
Feb 8th, 2008
Originally Posted by WolfPack View Post
I don't see anything wrong with checkIfMagic . But what is this function void ManiMatrix() in the first warning? Also make sure that Mani is not a misspelling for Main .
Well sorry I said in the main but I´m calling the customMatrix.checkIfMagic() from a function include in the main. I also calls another function from there without any problem. I use Void ManiMatrix to call the functions that are in the class.
Computer Science Student @ www.upra.edu
Camuy, PR USA
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Error when calling a method of dynamic array

 
0
  #4
Feb 8th, 2008
So what you're saying is that you have a function called ManiMatrix which is supposed to call customMatrix.checkIfMagic() ? In that case, could you post the the line in which you call checkIfMagic() in a little bit of context? The compiler error mentions 'int', which I haven't seen yet.

Please use code tags when you post code!
Last edited by John A; Feb 8th, 2008 at 10:54 pm.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 62
Reputation: kako13 is an unknown quantity at this point 
Solved Threads: 1
kako13's Avatar
kako13 kako13 is offline Offline
Junior Poster in Training

Re: Error when calling a method of dynamic array

 
0
  #5
Feb 9th, 2008
Originally Posted by joeprogrammer View Post
So what you're saying is that you have a function called ManiMatrix which is supposed to call customMatrix.checkIfMagic() ? In that case, could you post the the line in which you call checkIfMagic() in a little bit of context? The compiler error mentions 'int', which I haven't seen yet.

Please use code tags when you post code!
Yes, this is the code:
  1. void ManiMatrix ()
  2. { // ManiMatrix began
  3. matrix customMatrix;
  4.  
  5. customMatrix.createFile();
  6. customMatrix.readFileIntoArray();
  7. customMatrix.checkIfMagic();
  8. } // ManiMatrix end

Updated error:
Asig 2\Asig 2.cpp In function `void ManiMatrix()': 
Asig 2\Asig 2.cpp no matching function for call to `matrix::checkIfMagic()' 
Asig 2\matrix.h:118 candidates are: void matrix::checkIfMagic(int**) 
Asig 2\Makefile.win [Build Error]  ["Asig 2.o"] Error 1
Computer Science Student @ www.upra.edu
Camuy, PR USA
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Error when calling a method of dynamic array

 
0
  #6
Feb 9th, 2008
Well, that's because you coded your function to accept int ** as a parameter, and you're calling it without any arguments.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 62
Reputation: kako13 is an unknown quantity at this point 
Solved Threads: 1
kako13's Avatar
kako13 kako13 is offline Offline
Junior Poster in Training

Re: Error when calling a method of dynamic array

 
0
  #7
Feb 9th, 2008
Well I want to pass an array that is inside the class, how I do that?
I try this but I got error:

{ // ManiMatrix began
matrix customMatrix;

customMatrix.createFile();
customMatrix.readFileIntoArray();
customMatrix.checkIfMagic(arrayOfArray);
} // ManiMatrix end
 I:\Class\CCOM 4005\Asig\Asig 2\Asig 2.cpp In function `void ManiMatrix()': 
31 I:\Class\CCOM 4005\Asig\Asig 2\Asig 2.cpp `arrayOfArray' undeclared (first use this function) 
  (Each undeclared identifier is reported only once for each function it appears in.) 
 I:\Class\CCOM 4005\Asig\Asig 2\Makefile.win [Build Error]  ["Asig 2.o"] Error 1
Last edited by kako13; Feb 9th, 2008 at 6:27 pm.
Computer Science Student @ www.upra.edu
Camuy, PR USA
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Error when calling a method of dynamic array

 
0
  #8
Feb 9th, 2008
>Well I want to pass an array that is inside the class, how I do that?
I'm assuming you mean that the array is a member of matrix . In that case, you'd call the function like this:
  1. customMatrix.checkIfMagic( customMatrix.arrayOfArray );
Last edited by John A; Feb 9th, 2008 at 7:06 pm.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 62
Reputation: kako13 is an unknown quantity at this point 
Solved Threads: 1
kako13's Avatar
kako13 kako13 is offline Offline
Junior Poster in Training

Re: Error when calling a method of dynamic array

 
0
  #9
Feb 10th, 2008
Originally Posted by joeprogrammer View Post
>Well I want to pass an array that is inside the class, how I do that?
I'm assuming you mean that the array is a member of matrix . In that case, you'd call the function like this:
  1. customMatrix.checkIfMagic( customMatrix.arrayOfArray );
arrayOfArray is a dynamic array create inside a method of the class matrix , so is not in public or private area...
Computer Science Student @ www.upra.edu
Camuy, PR USA
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Error when calling a method of dynamic array

 
0
  #10
Feb 10th, 2008
Originally Posted by kako13 View Post
arrayOfArray is a dynamic array create inside a method of the class matrix , so is not in public or private area...
If it was created inside a member function, then the pointer is a local variable (even if the data isn't) and thus you'll lose the address of the data outside of the function. Either you need to declare arrayOfArray as a public/private member of matrix , or you need a pointer to it that is accessible within the scope of ManiMatrix().
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC