小编Jok*_*k3r的帖子

继续"错误:使用未声明的标识符'cout'和错误:无法解析对重载函数的引用

我正在编写一个使用许多不同函数的排序程序,你们可以从我的声明中看到.但是,当我尝试编译并运行我的程序时,我不断收到这些错误,如下所示:

  1. error: use of undeclared identifier 'cout'; did you mean 'count'?

    cout << "Hello from main" << endl;

  2. error: reference to overloaded function could not be resolved; did you mean to call it?

    cout << "Hello from main" << endl;

  3. error: use of undeclared identifier 'endl'; did you mean 'end'? cout << "Hello from main" << endl;

我不确定为什么我会收到这些错误....我认为我包含了所有我需要的东西,以便当我使用命名空间std时使用"cout"和"endl"...我有一种感觉它有与我所有的函数声明有关,但这只是一个预感任何你能给出的帮助都会非常感激!!!!!

#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

template <typename Comparable>
void insertionSort(vector<Comparable> & a);

template <typename Comparable>
void heapsort(vector<Comparable> & …
Run Code Online (Sandbox Code Playgroud)

c++ cout endl

4
推荐指数
3
解决办法
1万
查看次数

无法解决错误:间接需要指针操作数('int'无效)

我创建了一个顶点指针向量,现在我想将它们打印出来.我试图通过解除引用指针来打印它们,但是这没有用,我得到了错误:indirection requires pointer operand ('int' invalid).我之前打印过指针,但我从未遇到过这个错误.任何帮助都会很棒!提前致谢!

vector<Vertex*> vertices (numVertices + 1);

for(int i=1;i<=numVertices;i++)
{   
    file >> numEdges;
    cout << "At vertex " << i << " the number of edges is " << numEdges << endl;
    vertices[i] = new Vertex();
    //Vertex newVertex;

    //Using the i counter variable in the outer for loop to identify
    //the what vertex what are currently looking at in order to read in the correct adjacent vertex and weight
    vertices[i] -> setVertexNum(i);
    //newVertex.setVertexNum(i);

    for(int …
Run Code Online (Sandbox Code Playgroud)

c++ pointers

1
推荐指数
1
解决办法
5万
查看次数

标签 统计

c++ ×2

cout ×1

endl ×1

pointers ×1