#Help passing information

14 messages · Page 1 of 1 (latest)

jovial prairie
#

In my header file, i am trying to send inva11,inva12,inva21,inva22 to the method multiplication and from multiplication i am trying to send x, and y to method setAB, does anyone have any suggestion on how I can do this.

spring ridgeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

jovial prairie
#

void MatrixInverse (void)
{
double inva11, inva12, inva21, inva22;

        inva11 = (d/((a * d) - (b * c)));
        inva12 = (-b/((a * d) - (b * c)));
        inva21 = (-c/((a * d) - (b * c)));
        inva22 = (a/((a * d) - (b * c)));

        cout << "The inverse of the matrix is: " << endl;
        cout << "a11: " << inva11 << endl;
        cout << "a12: " << inva12 << endl;
        cout << "a21: " << inva21 << endl;
        cout << "a22: " << inva22 << endl;

    }
    void Multiplication(double alph, double bet)
    {
        double x, y;
        
        alpha = alph;
        beta = bet;

        x = (alpha * (d/((a * d) - (b * c)))) + (beta * (-b/((a * d) - (b * c))));
        y = (alpha * (-c/((a * d) - (b * c)))) + (beta * (a/((a * d) - (b * c))));
    }
    void SetAB (void)
    {
        x = (alpha * (d/((a * d) - (b * c)))) + (beta * (-b/((a * d) - (b * c))));
        y = (alpha * (-c/((a * d) - (b * c)))) + (beta * (a/((a * d) - (b * c))));

        cout << "Your x and y are: " << endl;
        cout << "x: " << x << endl;
        cout << "y: " << y << endl;
    }

};

spring ridgeBOT
#

```cpp
int main() {
return 0;
}
```

left ginkgo
#

you can make your inverse function modify the object members abcd instead

#

the code using this class should do get some return value from Multiplication (poor name btw needs to be more descriptive), then pass that along to SetAB

left ginkgo
#

You can return a struct or a pair of doubles

jovial prairie
#

I'm a beginner can you, maybe show me?

spring ridgeBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.

zealous falcon
#
struct foo
{
     int bar;
     int bar2;
}

Look here:
https://www.w3schools.com/cpp/cpp_structs.asp

jovial prairie
#

Thanks @zealous falcon

spring ridgeBOT
#

@jovial prairie Has your question been resolved? If so, run !solved :)

jovial prairie
#

!solved