错误:在“类”错误之前的预期初始化程序:在'=='标记之前的预期主表达式 [英] Error: Expected Initializer Before 'Class' Error: Expected Primary-Expression Before '==' Token

查看:745
本文介绍了错误:在“类”错误之前的预期初始化程序:在'=='标记之前的预期主表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做错了什么。我已经困惑了2个小时了。

What have i done wrong. i have been puzzled for 2 hours now.

#include "placeName.h"
#include <iostream>
#include <string>
using namespace std;
placeName::placeName()
class RandonRegionName{
    public:
{
    int P_Name(){
    srand(static_cast<unsigned int>(time(0)));
    int placeName = rand();

    return (placeName % 3) + 1;
}

    void randomPlaceName(){
        string RegionName;
       if (placeName == 1){
        RegionName = "Pandonia";

       }else if (placeName == 2){
         RegionName = "Shires";
       }else if (placeName == 3){
          RegionName = "Epic";
       }

    }}
};

推荐答案

错误的片段是line placeName :: placeName(),某种不完整的代码片段。去掉它。它甚至猜不出你背后的想法。



在C ++文本的顶层,你只能有任何类型的声明/定义,而不是任何东西其他如运算符,语句(函数调用)等。



-SA
The wrong fragment is the line placeName::placeName(), some kind of incomplete fragment of code. Remove it. It cannot even guess what could be your idea behind that.

On the top-level of C++ text, you can only have any kinds of declarations/definitions, not anything else like operators, statements (functions calls), etc.

—SA


这篇关于错误:在“类”错误之前的预期初始化程序:在'=='标记之前的预期主表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆