Thread: problem with a function

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    11

    problem with a function

    i wrote this function to find and return the determinant of a 3x3 matrix...

    Code:
    double getDeterminant(double (*matrix)[3])
    {
    	double a = matrix[0][0];
    	double b = matrix[0][1];
    	double c = matrix[0][2];
    	double d = matrix[1][0];
    	double e = matrix[1][1];
    	double f = matrix[1][2];
    	double g = matrix[2][0];
    	double h = matrix[2][1];
    	double i = matrix[2][2];
    
    	double det = a(e*i) - (f*h) - b(d*i) - (g*f) + c(d*h) - (e*g);
    
    	return det;
    }
    the error i get is the line with the equation and it says

    "error C2064: term does not evaluate to a function taking 1 arguments"

    thanks for any help you can give me.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    'a', 'b' and 'c' are not functions. They are variables. If you meant it to be a multiplication (like you would do in maths), you need to add a multiplication operator before the parenthesis. You can omit multiplication operators in maths, but not in C++.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    11
    ahh ty i feel stupid.

  4. #4
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    suggestion:
    itd be easier to change double a to i into an array and loop thru it

    OS: Windows 7, XUbuntu 11.10, Arch Linux
    IDE: CodeBlocks
    Compiler: GCC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 10-29-2008, 06:33 AM
  2. wxWidgets link problem
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2006, 02:36 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Problem with function pointers
    By vNvNation in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2004, 06:49 AM