Im need help the class

Pleas help in the programs i have 4 errors.
The program is : ”Write a class named Safe that has as private attributes the cipher and the amount of money. Implement the private accessor and mutator methods getMoney() and putMoney(). The public methods putInSafe() and getFromSafe() will call the previous methods only if the cipher sent as parameter matches the value stored inside the class. Display a message if the cipher is not correct.”

Im wrote in romanian.


//directive procesor
#include<stdio.h>

#include<iostream>
using namespace std; //specifica utilizarea de spatiu standard
#include<conio.h>

class Seif
{
string cifru;
int get_suma() const;
void set_suma(int valoare);
public: void set_cifru(const string &valoare)
{
cifru=valoare;
}
int puneInSeif(int val, int sumaInitiala);
int scoateDinSeif(int val, int sumaInitiala);
};
int Seif::puneInSeif()
{
return sumaInitiala+val;
}
int Seif::scoateDinSeif()
{
return sumaInitiala-scot;
}

void main()
{
Seif seif;
int sumaInitiala;
int alegere;
char cifru[20];
cout<<"Cata suma doriti sa introduceti in seif:";
cin>>sumaInitiala;
cout<<"Introduceti parola seifului:";
cin>>cifru;
if(!strcmp(cifru, "seif"))
cout<<"\t\t-------------------Cod Aceptat!!!-------------------------\n";
else
{
cout<<"Parola incorecta:";
return;
}
printf("In seif aveti urmatorarea suma: %d", sumaInitiala);
cout<<"Apasati:\n\t- apasati 1 pentru a pune in seif \n\t - apasati 2 pentru a scoate din in seif ";
cout<<"\n\t - apasati 3 pentru a verifica suma din seif\n";
cin>>alegere;

switch(alegere)
{
case 1:
{
int val;
cout<<"Introduceti suma pe care doriti sa o depuneti in seif:";
cin>>val;
seif.set_suma(val, sumaInitiala);
cout<<"Suma totala in seif dupa depunere este:%d "<<seif.puneInSeif(val,sumaInitiala);
cout<<"\t\t------------Proces finalizat cu succes!!!-----------------\n";
break;
}
case 2:
{
int scot;
printf("Introduceti suma pe care verti sa o scoateti din seif(introduceti o suma mai mica decat %d):",sumaInitiala);
cin>>scot;
cout<<endl;
seif.set_suma(scot,sumaInitiala);
cout<<"Suma totala dupa retragere din seif este:"<<seif.scoateDinSeif(scot,sumaInitiala);
cout<<endl;
cout<<"\t\t------------Proces finalizat cu succes!!!-----------------\n";
break;
}
case 3:
{
printf("Suma din seif pana la momentul %s la ora %s este de:%d lei\n",__DATE__, __TIME__, sumaInitiala);
cout<<"\t\t------------Proces finalizat cu succes!!!-----------------\n";
break;
}
}
}



Pleas help to repaire the errors. Is four errors.
Thanks in advence
You are declaring methods with 2 arguments
1
2
int puneInSeif(int val, int sumaInitiala);
int scoateDinSeif(int val, int sumaInitiala); 


but while defining them, you don't have any arguments
E.g.
 
int Seif::puneInSeif()


Definition should have same prototype as the declaration.
So it should be
 
int Seif::puneInSeif(int val, int sumaInitiala) 


Same goes for the other method.

Secondly,
 
return sumaInitiala-scot;

what is scot? shouldn't it be val?

Thirdly,
to use strcmp, you need to use its appropriate header

 
#include <cstring.h> 


Fourthly,
your main() is declared as void.
So why do you have
1
2
cout<<"Parola incorecta:";
return;

where is it returning to????


thank you verry mach, i resolved the problem
Topic archived. No new replies allowed.