标签: compiler-errors

另一个“在数字常量之前预期不合格的 id”错误

我正在尝试编写一个非常简单的 C/C++ 程序,在过去的几个小时里我一直在努力,但我找不到错误!这不是家庭作业,只是记住我的旧 C 的练习。

\n

主程序.c

\n
#include <iostream>\n#include "Persona.h"\n#include "BaseDeDatos.h"\n\nusing namespace std;\n\n#define agregarPersona      1\n#define eliminarPersona     2\n#define imprimirListado     3\n#define buscarPersona       4\n#define salir               5\n\nint main(){\n    BaseDeDatos datos("Personas.txt");\n\n    Persona piter(2000, "Andres Ledesma", "Cabrera 2000");\n    datos.agregarPersona(piter);\n\n    return 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

BaseDeDatos.h

\n
#ifndef BASEDEDATOS_H\n#define BASEDEDATOS_H\n\n#include "Persona.h"\n#include <inttypes.h>\n#include <vector>\n#include <string.h>\n#include <iostream>\n#include <stdio.h>\n#include <stdlib.h>\n\n#define identificadorNombre     '%'\n#define identificadorLegajo     '#'\n#define identificadorDomicilio  '$'\n\nclass BaseDeDatos{\n    public:\n        BaseDeDatos(char nombreDelArchivo[]);\n\n        void agregarPersona(Persona persona);\n        bool eliminarPersona(long legajo);\n        void imprimirListado();\n        void buscarPersona(char nombre[]);\n\n        ~BaseDeDatos();\n\n    private:\n        void obtenerLinea(unsigned int x, char buffer[]);\n        bool existeEnArray(unsigned …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors

-3
推荐指数
1
解决办法
1727
查看次数

'Category'(又名'OpaquePointer')类型的值没有成员'name'

我正在 Xcode 中使用 Swift,但收到以下错误:--“类别”类型(又名“OpaquePointer”)的值没有成员“名称”--我到处找,但找不到解决方案。有人知道该怎么做吗?

这是一个屏幕截图: 在此处输入图片说明

谢谢你的帮助!

xcode compiler-errors opaque-pointers swift

-3
推荐指数
1
解决办法
1907
查看次数

如何解决错误:无法将类型“long”隐式转换为“bool”?

using System;
using System.Linq;
    
namespace Problem
{
    class Prog
    {
        public static void Main(string[] args)
        {
            long t= long.Parse(Console.ReadLine());
         
            while (t-->0)
            {
                long n, even = 0, odd = 0, a;
    
                n = long.Parse(Console.ReadLine());
    
                for (long i = 0; i < n; i++)
                {
                    a = long.Parse(Console.ReadLine());
                    if (a % 2)
                        odd++;
                    else
                        even++;
                }
                Console.WriteLine((even < odd) ? even : odd);
                
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

由于我是 C# 新手,因此我正在使用此代码来解决hackerearth 中的问题,因此正在练习,但实际上我没有得到如何解决此错误的说法:

solution.cs(21,25):错误 CS0029:无法将类型“long”隐式转换为“bool”
编译失败:1 个错误,0 个警告`

c# compiler-errors

-3
推荐指数
1
解决办法
65
查看次数

为什么我的 int 函数收到警告:控制到达非 void 函数的末尾?

我有一个Largest接受三个参数ab和 的函数c。该函数旨在返回三个输入的最大值。但是,我在编译代码时遇到错误,指出该函数可能不会返回值。我不确定为什么会发生这个错误,因为我确实在函数中返回了一个值。

下面是我的 C++ 代码:

#include <stdexcept>

int Largest(int a, int b, int c) {
    if (a > b && a > c) {  
        return a;
    }
    else if (a < b && b > c) {
        return b;
    }
    else if (a < c && c > b) {
        return c;
    }
}
Run Code Online (Sandbox Code Playgroud)

任何帮助理解和解决此错误的帮助将不胜感激。

c++ compiler-errors return

-3
推荐指数
1
解决办法
138
查看次数

无法在 C++ 中使用 conio 库

我有一个作业,正在为它编写一个程序。我在我的程序中使用 clear() 和 getch() 函数。当我编译程序时,出现以下错误:

Fatal error: conio:no such file or directory 
Run Code Online (Sandbox Code Playgroud)

我在文件的开头插入了以下行:

#include <conio>
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题。

c++ compiler-errors fatal-error

-4
推荐指数
1
解决办法
2558
查看次数

Java“尝试而不捕获”和“捕获而不尝试”

我正在编写一个 Java 文件,但是当我尝试编译它时,我不断收到 3 条错误消息:

reader.java:35: 错误:'try' 没有 'catch'、'finally' 或资源声明 try

reader.java:48: 错误:'catch' 没有 'try' catch(IOException e)

reader.java:52: 错误: 'catch' 没有 'try' catch(Exception e)

3 错误

为什么?我错过了什么?这是我的代码:

public static void processRecords(String filenameIn, Person[] personArray)
{
    try 
    {
        FileReader fr = new FileReader(filenameIn);
        BufferedReader reader = new BufferedReader(fr);
        reader.readLine();

        for (int i = 0; i <personArray.length; i++)
        {
            String[] data = reader.readLine().split("/t");
            personArray[i] = new Person(Integer.parseInt(data[0]), data[1], data[2], Integer.parseInt(data[3]));
        }
    }
        reader.close();
    catch(IOException e)
    {
        System.out.println("ERROR: WRONG FILE " + e.toString()); …
Run Code Online (Sandbox Code Playgroud)

java compiler-errors exception try-catch

-4
推荐指数
1
解决办法
9533
查看次数

ARC 不允许将“int”隐式转换为“id _Nonnull”

这段代码:

[selectedTagIndexes addObject: (int)sender.tag - 100];
Run Code Online (Sandbox Code Playgroud)

产生一个错误:

ARC 不允许将“int”隐式转换为“id _Nonnull”

compiler-errors objective-c automatic-ref-counting

-4
推荐指数
1
解决办法
6372
查看次数

错误 java.lang.NoSuchMethodError:没有静态方法

我正在尝试从下面的 git 链接运行代码

https://github.com/Mikhail57/RetrofitTutorial

但我收到一个错误

java.lang.NoSuchMethodError:没有静态方法 getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)Landroid/graphics/Typeface; 在类 Landroid/support/v4/content/res/ResourcesCompat 中;或其超类(“android.support.v4.content.res.ResourcesCompat”的声明出现在 /data/app/com.stanlytango.android.secondfromgitretrofit-aDuaUJp0_br091ehbTa3bQ==/split_lib_dependency_apk.apk 中)

我的应用程序 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.stanlytango.android.secondfromgitretrofit"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
}
Run Code Online (Sandbox Code Playgroud)

活动_主布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" …
Run Code Online (Sandbox Code Playgroud)

java android compiler-errors

-4
推荐指数
1
解决办法
8048
查看次数

'transform': is not a member of 'std'

Here is my code

#include "pch.h"
#include <iostream>
using namespace std;

int main()
{
    // su is the string which is converted to lowercase
    std::wstring su = L"HeLLo WoRld";

    // using transform() function and ::toupper in STL
    std::transform(su.begin(), su.end(), su.begin(), ::tolower);
    std::cout << su << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

It generates the following compilation error.

1>c:\users\root\source\repos\consoleapplication7\consoleapplication7\consoleapplication7.cpp(14): error C2039: 'transform': is not a member of 'std'
1>c:\users\root\source\repos\consoleapplication7\consoleapplication7\consoleapplication7.cpp(14): error C3861: 'transform': identifier not found
1>c:\users\root\source\repos\consoleapplication7\consoleapplication7\consoleapplication7.cpp(15): error C2679: binary '<<': no operator found …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors visual-studio

-4
推荐指数
1
解决办法
281
查看次数

编译器认为使用 arg.getClass().cast(arg) 调用构造函数是递归的,尽管这是错误的

我有一个接口,它是和枚举Commodity的超类型。另外,还有一个具有多个构造函数的类:ItemConsumableOption

class Option{
    Option(Item c,int price){. . .}
    Option(Consumable c,int price){. . .}
    Option(Commodity c,int price){
        this(c.getClass()!=Commodity.class?c.getClass().cast(c):Item.EMPTY,price);
    }
}
}
Run Code Online (Sandbox Code Playgroud)

编译器认为这将导致无限递归,但显然不会。

Recursive constructor invocation Option(Commodity, int)

如何对他说“闭嘴,伙计,我知道我在做什么!”?

java compiler-errors class

-4
推荐指数
1
解决办法
78
查看次数