相关疑难解决方法(0)

我什么时候可以使用前瞻性声明?

我正在寻找允许在另一个类的头文件中进行类的前向声明的定义:

我是否允许为基类,作为成员持有的类,通过引用传递给成员函数的类等执行此操作?

c++ c++-faq forward-declaration

588
推荐指数
7
解决办法
23万
查看次数

C++初学者 - 在类中使用类时遇到麻烦

我正在做一个大学项目,我必须在那里实施一个简单的Scrabble游戏.

我有一个player班级(包含分数和玩家的手,形式为a std::stringscore类(包含名称和数字(int)分数).

其中一个Player成员函数是Score getScore(),返回该玩家的Score对象.但是,我在编译时遇到以下错误:

player.h(27) : error C2146: syntax error : missing ';' before identifier 'getScore'
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : warning C4183: 'getScore': missing return type; assumed to be a member function returning 'int'
player.h(35) : error C2146: …
Run Code Online (Sandbox Code Playgroud)

c++ class return-type header-files

0
推荐指数
1
解决办法
1493
查看次数

错误C2923:'std :: vector':'Edge'不是参数'_Ty'的有效模板类型参数?

嗨...

    #ifndef Node_H
    #define Node_H
    #include <vector>
    #include <stack>
    #include <string>
    #include <iostream>
    #include "Edge.h"
    #include "CongestionMap.h"
    using namespace std;   
    class Node
    {

    public:
        Node(){ visit = false;};
    Node(int id);
    ~Node(); 
    int getID();
    void setLocation(int &row, int &col, GridCell *Gc);;
    void displayList();

    private:
        int row;
        int col;
        int id;
        bool visit;
        int parrent;
        int distance;
        typedef vector<  Edge > adjNodeList;

    };
    #endif 
Run Code Online (Sandbox Code Playgroud)

当我编译项目时,我得到错误为project \node.h(43):错误C2065:'Edge':未声明的标识符project\project \node.h(43):错误C2923:'std :: vector':'Edge '不是参数'_Ty'的有效模板类型参数...请帮帮我... Edge.h

#ifndef Edge_H
#define Edge_H
#pragma once
#include <vector>
#include <stack>
#include …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
6389
查看次数