Bonjour,
je dois utiliser un pointeur de fonction mais je sais pas comment faire pour la déclarer en attribut d'une classe sachant quel fera référence à des méthodes de la mếme classe et elle sera appelé dans le code du fichier.cpp. Mon code sera mieux pour comprendre.
fichier .h
fichier .cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
67
68
69 #ifndef MYERSMILLERPROFILEALIGN_H #define MYERSMILLERPROFILEALIGN_H #include <vector> #include "ProfileAlignAlgorithm.h" #include "ProfileStandard.h" #include "ProfileWithSub.h" namespace clustalw { class MyersMillerProfileAlign : public ProfileAlignAlgorithm { public: virtual ~MyersMillerProfileAlign(){}; /* Functions */ MyersMillerProfileAlign(); virtual int profileAlign(Alignment* alnPtr, DistMatrix* distMat, vector<int>* group, int* aligned); /* Attributes */ int (*scoreFunction)(int n, int m); //pointeur sur fonction private: /* Functions */ void addGGaps(Alignment* alnPtr, SeqArray* seqArray); void addGGapsMask(vector<char>* mask,int len, vector<int>* path1, vector<int>* path2); int prfScore(int n, int m); int prfScoreMotif(int n, int m); int progTracepath(); void progDel(int k); void progAdd(int k); void progAlign(); int progDiff(int A, int B, int M, int N, int go1, int go2); int openPenalty1(int i, int j); int extPenalty1(int i, int j); int gapPenalty1(int i, int j, int k); int openPenalty2(int i, int j); int extPenalty2(int i, int j); int gapPenalty2(int i, int j, int k); /* Attributes */ ProfileWithSub* profileWithSub; ProfileStandard* profileStandard; int gapcoef1; int gapcoef2; int lencoef1; int lencoef2; vector<int> displ; vector<int> gS; vector<int> HH; vector<int> DD; vector<int> RR; vector<int> SS; vector<int> alnPath1; vector<int> alnPath2; int printPtr; int lastPrint; int matrix[32][32]; vector<int> gaps; bool switchProfiles; const SeqArray* profile1; const SeqArray* profile2; int _gapPos1, _gapPos2; int alignmentLength; int **motif_score; }; } #endif
Donc j'ai une erreur à la compilation, qui me dit que j'appelle mal mon pointeur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
67
68
69
70
71
72
73
74
75
76
77
78
79 #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "MyersMillerProfileAlign.h" #include "Iteration.h" #include <math.h> namespace clustalw { /** * * @return */ MyersMillerProfileAlign::MyersMillerProfileAlign() : _gapPos1(userParameters->getGapPos1()), _gapPos2(userParameters->getGapPos2()) { } /** * * @param alnPtr * @param distMat * @param group * @param aligned * @return */ int MyersMillerProfileAlign::profileAlign(Alignment* alnPtr, DistMatrix* distMat, vector<int>* group, int* aligned) { //cout<<"ProfileAlign"<<endl; bool negative = false; int i = 0, j = 0, count = 0; int numSeq = 0; int seqNum = 0; int len = 0, len1 = 0, len2 = 0, is = 0, minLen = 0; int se1 = 0, se2 = 0, sb1 = 0, sb2 = 0; int maxRes = 0; int c = 0; int score = 0; double logmin = 0.0, logdiff = 0.0; double pcid = 0.0; int matrix[NUMRES][NUMRES]; int numSeqsProf1 = 0, numSeqsProf2 = 0; //[......................] HH.resize(_maxAlnLength + 1); DD.resize(_maxAlnLength + 1); RR.resize(_maxAlnLength + 1); SS.resize(_maxAlnLength + 1); gS.resize(_maxAlnLength + 1); displ.resize(_maxAlnLength + 1); //appelle du pointeur sur fonction membre if(motif_score!=NULL) { if(isprf1==FALSE) scorefunction=seqseqscoremotif; else if(isprf2==FALSE) scorefunction=prfseqscoremotif; else scorefunction=prfprfscoremotif; /*else scorefunction=prfprfscore1motif;*/ } else { if(isprf1==FALSE) scorefunction=seqseqscore; else if(isprf2==FALSE) scorefunction=prfseqscore; else scorefunction=prfprfscore; /*else scorefunction=prfprfscore1;*/ } score = progDiff(sb1, sb2, se1 - sb1, se2 - sb2, (*profile1)[0][GAPCOL], (*profile1)[prfLength1][GAPCOL]); // May not need if we recreate the Profile every time! HH.clear(); DD.clear(); RR.clear(); SS.clear(); gS.clear(); //[...]
Avez-vous une idée de comment faire?
J'ai trouvé des choses sur le net mais c'est pour appelé le pointeur dans le main mais pas dans la même classe.
Merci
alaninho
Partager