Member function is not declared in this scope

Hi, I have written a simple C++ program as exercise and I need help (Sorry the ex is in french) And while finishing the main program this error occurred and I could not finish it:

I'm using Eclipse CTD on Kubuntu 19.04

cannot declare member function ‘static void Compte::trfAgt(float, Compte, Compte)’ to have static linkage [-fpermissive] compte.cpp /Banque line 30 C/C++ Problem

main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * main.cpp
 *
 *  Created on: Oct 23, 2019
 *      Author: droidzed77
 */
//The directives

#include "compte.h"
#include <iostream>
#include <algorithm>

//THe namespace(s)
using namespace std;

//Main function
int main(){

//Vars

	Compte A,B;

	float montant(100), Nmontant(0);

//Filling the object A box

	cout << "Num de compte : ";
		cin >> A.numCompte;

	cout << "Nom propriétaire : ";
		cin >> A.nomProp;

	replace(A.nomProp.begin(),A.nomProp.end(), '_', ' ');

	cout << "Solde du compte : ";
		cin >> A.solde;

	A.deposerArgent(montant);

	A.consulterSolde();

//Filling the object B box

	cout << "Num de compte : ";
		cin >> B.numCompte;

	cout << "Nom propriétaire : ";
		cin >> B.nomProp;

	replace(B.nomProp.begin(),B.nomProp.end(), '_', ' ');

	cout << "Solde du compte : ";
		cin >> B.solde;

	B.consulterSolde();


	cout << "Donnner le montant à transferer : ";
		cin >> Nmontant;

	trfAgt(Nmontant,A,B);

	B.consulterSolde();
	A.consulterSolde();
	return 0;
}

Compte.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * compte.h
 *
 *  Created on: Oct 23, 2019
 *      Author: droidzed77
 */

#ifndef COMPTE_H_

#define COMPTE_H_



#include <iostream>
#include <string>

class Compte{

public:
	int numCompte;

	std::string nomProp;

	float solde;

	bool retirerArgent(float);

	void deposerArgent(float), consulterSolde();

	static void trfAgt(float,Compte,Compte);
};

#endif /* COMPTE_H_ */ 

Compte.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * compte.cpp
 *
 *  Created on: Oct 23, 2019
 *      Author: droidzed77
 */
#include "compte.h"
#include <iostream>
#include <string>

bool Compte::retirerArgent(float x){

	if (solde >= x) { solde -= x; std::cout << "Solde retiré." << std::endl; return true; }

	else {std::cout << "Solde insuffisant!" << std::endl;return false;}

}


void Compte::deposerArgent(float a) {

	solde += a;

}
void Compte::consulterSolde(){

	std::cout << "Le solde du compte " << numCompte << " est : " << solde << std::endl;

}
static void Compte::trfAgt(float somme,Compte c1, Compte c2){

	if (c1.solde > somme) { c2.solde += somme; c1.solde -= somme; }

	else { std::cout << "Solde insuffisant !" << std::endl; }

}
See: https://en.cppreference.com/w/cpp/language/static

The keyword "static" is only in the declaration, not in the definition.

And:
Inside a class definition, the keyword static declares members that are not bound to class instances.

Outside a class definition, it has a different meaning: see storage duration.
I ran into another issues :

trfAgt could not be resolved.
Function trfAgt was not declared in this scope

I already included the class header and the build failed.

And finally, the breakpoint thing ? I really don't know a lot of C++ as I'm learning it in college.
Please help me tackle these errors :)
trfAgt could not be resolved.
Function trfAgt was not declared in this scope

That is an error message from the compiler. It should include what file and which line, i.e. where the compiler encountered the problem.

I guess that it is within you main(), but could you show the code?
Topic archived. No new replies allowed.