0

This is my first time working with C++ and I have put together this program and came up with two errors and I am unsure what it is wanting me to do. The errors I got are:
1>c:\users\owner\documents\visual studio 2010\projects\week5\week5\passing_by_value.cpp(30): error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\owner\documents\visual studio 2010\projects\week5\week5\passing_by_value.cpp(38): error C2064: term does not evaluate to a function taking 1 arguments

#include<iostream>

using std::cin;
using std::cout;
using std::endl;

//initialize arrays
int incr10(int* numa,int* numb);

int main(void)
{
  cout << "Week 5 assignment part 1-Pass by pointer" << endl << endl;

  int numa = 3;
  int numb = 32;

  int* pnuma = &numa;                           //pointer to numa
  int* pnumb = &numb;                           //pointer to numb

  cout << endl
       << "Address Pass (numa)= " << pnuma;

  cout << endl
       << "Address Pass (numb)= " << pnumb;


  int result = incr10(pnuma,pnumb);

  cout << endl
       << "incr10(pnuma) = " << result (numa);

  cout << endl
       << "numa = " << numa;

  cout << endl;

  cout << endl
       << "incr10(pnumb) = " << result (numb);

  cout << endl
       << "numb = " << numb;

  cout << endl;


  return 0;
}


//function to increment a variable by 10
int incr10(int* numa,int* numb)
{
  cout << endl
       << "Address received (numa)= " << numa;

  cout << endl
       << "Address received (numb)= " << numb;

  numa += 10;                              // Increment argument
  numb += 10;

  return *numa,*numb;                      // return the increment value
}
2
Contributors
1
Reply
11
Views
2 Years
Discussion Span
Last Post by Ancient Dragon
0

lines 30 and 38: result() is not a function that has been previously declared.

line 62; Functions can only return one variable, not two.

It seems you have misunderstood the assignment. incr10() has two parameters passed by reference, not by value. Do not use the * when passing by value.

int incr10(int numa,int numb)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.