-1

I'm a beginner in c++ beginner and I don't know how to fix the errors in this code. Could you please help me to find out what's wrong with it? Thank you so much!

#include<iostream>
using namespace std;

class vector{
public:
   int xvalue;
   int yvalue;
};

vector obj1;
vector obj2;


int main()
{
   int mode;
   cin >> mode;

   if(mode == 0){

      cin >> obj1.xvalue;
      cin >> obj2.xvalue;

      addvecx(obj1.xvalue, obj2.xvalue);
   }
   else if(mode == 1){
     cin >> obj1.yvalue;
     cin >> obj2.yvalue;
     addvecy(obj1.yvalue,obj2.yvalue);
   }
 
   return 0;
};

int addvecy(obj1.yvalue, obj2.yvalue){ 
   sum=obj1.yvalue+obj2.yvalue;
   return sumy;
}

int addvecx(obj1.xvalue, obj2.xvalue){
   sum=obj1.xvalue+obj2.xvalue;
   return sumx;
}
drescherjm
  • 9,653
  • 5
  • 43
  • 62
ysho3
  • 1
  • Specifying what in the dupe is relevant: You attempt to use `addvecx` before you've provided a declaration of it. Although your definitions of `addvecx` and `addvecy` aren't correct--they should look something like `int addvecx(vector obj1, vector obj2)`, maybe. – Nathan Pierson May 20 '22 at 15:49

0 Answers0