-2

I've created two classes in c++ one called compte and the other bank

class compte
{
    public:
        compte();
        compte(long,float);
        virtual ~compte();

        long Getnum() { return num; }
        void Setnum(long val) { num = val; }
        float Getsolde() { return solde; }
        void Setsolde(float val) { solde = val; }
        void deposerArgent(float);
        void retirerArgent(float);
        virtual void afficher ();
         protected:
        long num;
        float solde;
};

And the other is banque:

class banque
{
    public:
        banque();
        virtual ~banque();
        string Getnom() { return nom; }
        void Setnom(string val) { nom = val; }
        string Getlieu() { return lieu; }
        void Setlieu(string val) { lieu = val; }
        list<compte*> Getcompte() { return compte; }
        void Setcompte(list<compte*> val) { compte = val; }
    protected:
    private:
        string nom;
        string lieu;
};

But I'm getting 2 errors in the following line of banque class list<compte*> Getcompte() { return compte; }:

expected primary-expression before ';' token

expected unqualified-id before '=' token
Chris
  • 26,361
  • 5
  • 21
  • 42

1 Answers1

1

Your methods frombanque have no access to any variable named compte. This is neither an attribute of your class, nor an argument, nor a global variable.

You can read the answer to this post to know what's an unqualified-id:

What are qualified-id/name and unqualified-id/name?

Actually, in the code you are showing, compte is a class name, not a variable. It means that compte represents a type (just like std::string or int would), not a value. Including it will only make the class declaration visible.

I'm only guessing here but what you need may be to add a compte attribute of type compte in your class banque (you might want to rename them to avoid confusion).