Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 913435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:33:29+00:00 2026-05-15T17:33:29+00:00

Hi I am trying to init an object with a double value in the

  • 0

Hi I am trying to init an object with a double value in the format double filter[3][3];
but i keep getting the following error.

cannot convert ‘double[3][3]’ to ‘double’ in assignment.

in my header i have this

@interface filter : NSObject
{
    double **matrix;
}
@property(nonatomic)double **matrix;
-(id)initWithMatrix:(double**)filterMatrix;

inside my class i have this method.

-(id)initWithMatrix:(double**)filterMatrix
{
    matrix = filterMatrix;
    return self;
}

and i am trying to call it like this.

double filter[3][3] = {0,0,0,0,1,0,0,0,0};
MyMatrix *myMatrix = [[MyMatrix alloc] initWithMatrix:filter];

I now get the error.

Error: Cannot convert double[*][3] to double** in argument passing

Any help on this issue would be amazing.
Thanks
A

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:33:30+00:00Added an answer on May 15, 2026 at 5:33 pm

    A two-dimensional array is not the same thing as a pointer-to-a-pointer. You have two choices – change the filter class to contain a 2D array, or change your initialization to use pointer-to-pointers.

    In choice #1, you’re could keep a copy of the array in your filter instance, instead of just holding a pointer. You need to change the class interface:

    @interface filter : NSObject
    {
        double matrix[3][3];
    }
    
    -(id)initWithMatrix:(double[3][3])filterMatrix;
    

    Then your implementation of initWithMatrix: can just do a memcpy() or the equivalent to copy the data into your instance.

    Choice #2 is a bit different. Keep your other code the way it is, but change your initialization of filter:

    double row0[3] = {0,0,0};
    double row1[3] = {0,1,0};
    double row2[3] = {0,0,0};
    double **filter[3] = { row0, row1, row2 };
    

    It’s probably safer to malloc() all of those arrays, since otherwise you’re going to end up with references to stack variables in your filter class, but I think you get the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to convert array object into string but still it is returning
I'm trying to extend jQuery with the following: $.fn.extend({ initCore: $.fn.init, init: function (selector,
I trying to use the module pattern with JS. But when I call HM.init()
I'm trying to figure out why the following example won't work. class BaseClass(object): def
I'm trying to init a var in JS with date from another JS object
I'm trying to achieve the following: class Data(object): def __init__(self, data): self.data = data
What I am trying to achieve is something like this: class object: def __init__(self):
Trying to add init parameter names to a list in init(ServletConfig) method. public void
I have been trying to make an init script using start-stop-daemon. I am stuck
I am trying to get my Chrome Extension to run the function init() whenever

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.