Hello DaniWeb, I am pretty new to this community and overall to the C++ language. Not so long ago i've decided to learn C++.
Anyways the problem is:
I am trying to make a simple calculator, its very easy my problem is i am trying to advance my knowlege about the structure so i was trying to make a calculator using only structure based variables, my question is:

When i take a normal integer variable for example:

int x,y,z;
z=x+y;

would compile correctly
but
if i would make a structure called database example:

struct database{ int x,y,z};
database get;
get.z=get.x+get.y;

would not be correct how can i make it correct if possible?
Here is the source code i've made so far:

#include<iostream>
#include<conio.h>

using namespace std;


struct database{/*Structure start.*/
              int loop;
              string choice,var1,var2,combined;
            
                           
              };/*Structure ends.*/
     
             
              
           database calc(database get); 


int main(){
    
 database get,*p;
 
 p=&get; /*Point's the pointer into the database. just testing*/ 
 get.loop=0;
 while(get.loop<1){
 /*First question*/
    cout<<"Welcome to the <M>aster <B>laster Calculator!\nPlease type one of the words below afterwards press enter.\nPlus\nMinus\nMultiple\nDivide\n\nChoice:";              
 /*Input of choices*/   
    cin>>get.choice;
    calc(get);
}
}

 

  database calc(database get){
              
                   if((get.choice=="Minus")||(get.choice=="minus")){
    cout<<"Please choose the first number:";
    cin>>get.var1;
    cout<<"Please choose the second number:";  
    cin>>get.var2;
   get.var1=get.var1-get.var2; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Error occurs here!!
    cout<<"\nThe answer is:"<<get.var1<<"-"<<get.var2<<"="<<"\n";
    
    }  
}

I've marked where the compiler Dev-C++ bloodshed see the errors by a comment(in line 43).
Thank you for all the contributors and have a good day.

You can't subtract strings.

commented: Helped me solve the whole problem with a very simple answer. +0

ok that solved everything thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.