Various token errors in c++ code?

时间:2015-12-10 01:50:56

标签: c++

So I'm doing an assignment for my intro c++ course and I continue to receive token errors like expected '}' at the end of input and expected ';' before '{' token. I'm suppose to make this code be able to store a graph and I'm taking it step by step, still tryna figure out, but cant get past these errors. (rookie). If there is anything I can do please criticize me.

#include<iostream>
#include<string>
#include<vector>
using namespace std;

template <class T>
class Node                        
{                                 //currently private members
 int number;
 T value;

 public:

 Node()                       //constructors never have a return type, constructor name is same as class name
 {
     number=1;               //initial value of number
     T replace;
     value= replace;
 }
};

template <class T>
class Edge                       
{
Node<T> edge_one;           //Two data members of type Node<T>, one member    called edge_one and another called edge_two
Node<T> edge_two;
};





template <class T>
class Graph                      //only storing two data using free store and implementing seven functions
{

Node<T>* v= new Node<T>;           //using pointer and new to store data
Edge<T>* e= new Edge<T>; 

 public:

 Graph()
 {

 GetAllVertices(v)
 {
vector<v> vex;
for(vex[i]=0; i < vex.size; i++){
    return vex;
}
}

GetAllEdges(e)
{
   vector<e> edg;
   for(vex[i]=0; i< edg.size; i++){
    return edg;
}
}

}

int main()
{
  return 0; }

1 个答案:

答案 0 :(得分:0)

保持代码非常有价值(特别是标准化缩进)。它将帮助您更轻松地找到这些不匹配的支具问题。

如果您编写漂亮的代码来开始会更容易,但您可以使用编辑器来提供帮助。如果您的编辑器没有代码重新格式化功能,请考虑获取另一个编辑器。大多数编辑器也会找到匹配的匹配功能。如果您将光标放在大括号,括号或括号上,大括号匹配键将找到相应的打开或关闭,您可以验证这是否符合预期。