Problème de portage d'un source créé sous Console vers MFC SDI
Bonjour !
J'ai testé en premier sous une application console un fichier H et CPP pour test, ça marche et il n'y a aucune erreur de compilation ni de warning.
Mais que je transporte les deux fichiers sur une nouvelle application MFC en interface sur une seule fenêtre (SDI), il se produit plusieurs erreurs (pour mon cas, c'est au nombre de 94) même si j'ai mis l'inclusion de "stdafx.h", voici quelques unes de ces erreurs:
sur la ligne 59:
d:\graphe gui\graph.h(59) : error C2143: syntax error : missing ';' before '*'
d:\graphe gui\graph.h(59) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\graphe gui\graph.h(59) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\graphe gui\graph.h(59) : warning C4183: 'findArc': missing return type; assumed to be a member function returning 'int'
qui contient le code:
Code:
Arc * findArc(const std::string& StartNodeLabel, const std::string& EndNodeLabel);
Or, tout est OK, la classe Arc est bien déclarée et définie.
Je l'ai testé sur VS 2003 mais ça bogue trop même pour:
Code:
vector<vector<int>> tab(5, vector <int>(6));
où il faut mettre un espace pour que ça marche :
Code:
vector<vector<int> > tab(5, vector <int>(6));
, cette version est loin d'être fiable (bizarre) donc je suis passé à VS 2005 et le nombre d'erreurs est descendu mais encore au nombre de 94.
Voici une partie du code (le fichier H) qui ne contient aucune erreur syntaxique ni sémantique, je ne sais plus quel est le problème, peut-être une manque des include puisqu'on travaille sous MFC, faut-il ajouter des directives #if, #endif ?
Code:
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
| #include "stdafx.h"
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
class SquareMatrix : protected std::vector<int>
{
public:
SquareMatrix(unsigned int _n=0);
int& operator ()(int i, int j);
int operator ()(int i, int j) const;
SquareMatrix operator +(const SquareMatrix& A) const;
SquareMatrix operator *(const SquareMatrix& A) const;
private:
unsigned int n;
};
class Node
{
public:
Node(const std::string& _Label);
std::string getLabel() const;
void addNextNode(Node * _NextNode);
void addPreviousNode(Node * _NextNode);
void explore(std::list<Node *>& ReachableNodes);
friend class OrientedGraph;
private:
std::string Label;
std::list<Node *> PreviousNodes;
std::list<Node *> NextNodes;
};
class Arc
{
public:
Arc(Node * _StartNode, Node * _EndNode, double _Weight=1.0);
Node * getStartNode() const;
Node * getEndNode() const;
double getWeight() const;
private:
Node * StartNode;
Node * EndNode;
double Weight;
};
class OrientedGraph
{
public:
OrientedGraph():UpToDate(false){}
~OrientedGraph() {}
bool addNode(const std::string& NewNodeLabel);
bool addArc(const std::string& StartNodeLabel, const std::string& EndNodeLabel,double Weight=1.0);
Node * findNode(const std::string& NodeLabel);
Arc * findArc(const std::string& StartNodeLabel, const std::string& EndNodeLabel);
void computeTransitiveClosure();
void getReachableNodesFrom(const std::string& SourceNodeLabel,std::list<Node *>& ReachableNodes);
bool isStronglyConnected();
void getMaximalStronglyConnectedComponentFrom(const std::string& SourceNodeLabel,std::list<Node *>& ConnectedNodes);
private:
std::list<Node *> NodesList;
std::list<Arc *> ArcsList;
std::vector<SquareMatrix> A;
bool UpToDate;
}; |