Advertisement

Help me i have a problem

Started by June 03, 2018 05:27 PM
3 comments, last by Bradley Latreille 6 years, 6 months ago

// at int main is say 


main.cpp: In function 'int main()':
main.cpp:70:25: error: expected primary-expression before 'int'
              v.LlogInte(int bilanci,double interes);
                         ^
main.cpp:70:37: error: expected primary-expression before 'double'
              v.LlogInte(int bilanci,double interes);
                                     ^
main.cpp:73:25: error: expected primary-expression before 'int'
              v.terheqje(int vlera,int bilanci);
                         ^
main.cpp:73:35: error: expected primary-expression before 'int'
              v.terheqje(int vlera,int bilanci);
                                   ^
main.cpp:76:27: error: expected primary-expression before 'int'
               v.depozitim(int bilanci,int vlera);
                           ^
main.cpp:76:39: error: expected primary-expression before 'int'
               v.depozitim(int bilanci,int vlera);

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
class Vep{
    int bilanci;
    int vlera;
    double interes;
    public:
 void LlogInte(int bilanci,double interes){
     cout<<"jepni bilancin:";
     cin>>bilanci;
     cout<<"jepni Interesin:";
     cin>>interes;
    bilanci= bilanci + (bilanci*interes/100);
    cout << "totali i shumes se mbetur ne  llogarise eshte " << bilanci <<endl;
  }
  void terheqje(int vlera,int bilanci) {
     cout<<"jepni bilancin:";
     cin>>bilanci;
     cout<<"jepni vleren:";
     cin>>vlera;
  bilanci = bilanci - vlera;
  cout << "totali i shumes se mbetur ne  llogarise eshte " << bilanci<<endl;
  }
  void depozitim(int bilanci,int vlera)
  {
     cout<<"jepni bilancin:";
     cin>>bilanci;
     cout<<"jepni vleren:";
     cin>>vlera;
  bilanci = bilanci + vlera;
  cout << "totali i shumes se mbetur ne  llogarise eshte " << bilanci <<endl;
      }
};
 
int main () {
Vep v ;
 string Emer;
 string mbiemer;
 string datelindje;
 string Qyteti;
 string pergjigja;
 string veprimi;
 
 
 ofstream sked ("Test1.txt");
 if (sked.is_open()) {
     do{
         
          cout << "Jepni emrin e Klientit" << "\n";
         cin>> Emer;
          cout << "Jepni mbiemerin e Klientit" << "\n";
         cin>> mbiemer;
          cout << "Jepni Datelindjen e Klientit" << "\n";
         cin>> datelindje;
          cout << "Jepni Qytetin" << "\n";
         cin>>Qyteti;
          
         
         sked<<Emer;
         sked<<mbiemer;
         sked<<datelindje;
         sked<<Qyteti;
         
         cout<<"Cfare veprimi?"<< endl;
         cin>>veprimi;
         if  (veprimi=="LlogInte"){
             v.LlogInte(int bilanci,double interes);
         }
          if  (veprimi=="terheqje"){
             v.terheqje(int vlera,int bilanci);
         }
          if  (veprimi=="depozitim"){
              v.depozitim(int bilanci,int vlera);
         }
             

  cout<<"Deshironi te shtoni kliente te tjere?Po/Jo"<<endl;
         cin>>pergjigja;
    }while(pergjigja=="Po");
     sked.close();
 }
    return 0;
 }

When you call a function, you should not include the type.

Hello to all my stalkers.

Advertisement

main.cpp:70:25: error: 'bilanci' was not declared in this scope
              v.LlogInte(bilanci,interes);
                         ^
main.cpp:70:33: error: 'interes' was not declared in this scope
              v.LlogInte(bilanci,interes);
                                 ^
main.cpp:73:25: error: 'vlera' was not declared in this scope
              v.terheqje(vlera,bilanci);
                         ^
main.cpp:73:31: error: 'bilanci' was not declared in this scope
              v.terheqje(vlera,bilanci);
                               ^
main.cpp:76:27: error: 'bilanci' was not declared in this scope
               v.depozitim(bilanci,vlera);
                           ^
main.cpp:76:35: error: 'vlera' was not declared in this scope
               v.depozitim(bilanci,vlera);

now is say this i remove all int and double

 

Your error is happening when you attempt to call you Class' functions. Notice that you are using the function v.LlogInte(bilanci, interes); and passing the parameters using object names that aren't created yet. The main function doesn't know what bilanci, or interes is, whoever our class does. We want to create a variable to store a temp_bilanci and temp_vlera, these would need to be created first, and then we can pass them to our functions. Just remember that if something was not declared in this scope, that means you are using, passing, ect,. a variable that doesn't exist in the scope of the main method. 

This topic is closed to new replies.

Advertisement