Depth First Search and Breadth First Search in C++
The implementation of the BFS and DFS algorithms themselves seems correct(but it is a good practice to write unit-tests to make sure that it works as intended, so you should do it). However, your code in general is not correct. It definitely leaks memory:


In the constructor, Adj is allocated: Adj = new vector&lt;int&gt;[V];. However, it is never deleted. You can do it in a destructor.
The same is true for the visited array(you should delete it at the end of the DFS and BFS member-functions).


Actually, there is a much easier way to deal with this issue: do not use pointers and dynamic memory allocation. I do not see any point in visited being allocated dynamically. Using an std::vector is much better(std::vector&lt;bool&gt; visited(num_of_vertices)). The same holds true for the Adj member-variable. 

One more thing: you should try to keep the scope of variables as narrow as possible. There is no need to declare the vector&lt;int&gt;::iterator i at the beginning of the function. You can do it just inside the for loop where it is used. 

The last thing: using namespace std; is a bad practice. It pollutes the global namespace.