V
V
vladpenziy132020-10-02 15:31:30
C++ / C#
vladpenziy13, 2020-10-02 15:31:30

Why aren't c++ values ​​assigned?

int input(TComplex a, TComplex b, TVect first, TVect second, float one )
{
    cout << "First complex.Enter real number:";
    cin >> &a->re;
    cout << "Enter imaginary number:" << endl;
    cin >> &a.im;
    cout <<"Second complex.Enter real number: ";
    cin >> &b.re;
    cout << "Enter imaginary number: ";
    cin >>&b.im; 
    cout << "First coordinate. X:";
    cin >> &first.x;
    cout << "Y:";
    cin >> &first.y;
    cout << "Second coorditane. X:";
    cin >> &second.x;
    cout << "Y:";
    cin >> &second.y;
    cout << "Enter a float nubmer";
    cin >> &one;
    cout << double(a.re)<< double(a.im)  << double(b.re)<<double(b.im)  << float(one)   << int(first.x)   << int(second.x)<< endl;
}
int main(void)
{   
    TComplex a,b;
    TVect first,second;
    float one;
    input(a,b,first,second,one);
    function(a,b);
    cout << double(a.re)<< double(a.im)  << double(b.re)<<double(b.im)  << float(one)   << int(first.x)   << int(second.x);

The values ​​that I registered do not reach the main.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2020-10-02
@vladpenziy13

Because you are passing by value (which means the function will get a copy of the argument), but you have to pass by reference:

int input(TComplex& a, TComplex& b, TVect& first, TVect& second, float& one )
{

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question