修了些bug

This commit is contained in:
2024-12-05 01:35:52 +08:00
parent 238975f638
commit b0f712fa4a
4 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -30,7 +30,7 @@ private:
T weight;
struct node* next;
};
vector<node> nodes;
vector<node*> nodes;
int max_size;
public:
@@ -40,11 +40,12 @@ public:
}
void insert(T data) {
max_size++;
node insert = new node();
node* insert = new node();
insert->data=max_size;
insert->weight = 0;
insert->next=new node();
insert->next->data=data;
insert->next->next=NULL;
nodes.push_back(insert);
}
void connect(int id1,int id2,bool flag,T weight=0) { //flag区分是否为有向图
@@ -11,7 +11,7 @@ private:
public:
NodeIdOutOfRangeException():message("You input id is out of range"){}
NodeIdOutOfRangeException(const std::string& msg) : message(msg) {}
NodeIdOutOfRangeException(const std::string& msg,int errCode):message(msg+"Err code: "+std::to_string(errCode)){}
NodeIdOutOfRangeException(const std::string& msg,int errCode):message(msg+" Err code: "+std::to_string(errCode)){}
virtual ~NodeIdOutOfRangeException() noexcept {}
virtual const char* what() const noexcept override {
@@ -12,7 +12,7 @@ private:
public:
SameNodeConnectException():message("Don't connect same node"){}
SameNodeConnectException(const std::string& msg) : message(msg) {}
SameNodeConnectException(const std::string& msg,int errCode):message(msg+"Err code: "+std::to_string(errCode)){}
SameNodeConnectException(const std::string& msg,int errCode):message(msg+" Err code: "+std::to_string(errCode)){}
virtual ~SameNodeConnectException() noexcept {}
virtual const char* what() const noexcept override {
+1
View File
@@ -25,4 +25,5 @@
using namespace std;
int main() {
return 0;
}