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;

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

struct database{ int x,y,z};
database get;

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


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*/ 
 /*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*/   


  database calc(database get){
    cout<<"Please choose the first number:";
    cout<<"Please choose the second number:";  
   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.

Recommended Answers

All 2 Replies

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, learning, and sharing knowledge.