我正在尝试编写一个非常简单的 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}\nRun Code Online (Sandbox Code Playgroud)\nBaseDeDatos.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) 我正在 Xcode 中使用 Swift,但收到以下错误:--“类别”类型(又名“OpaquePointer”)的值没有成员“名称”--我到处找,但找不到解决方案。有人知道该怎么做吗?
谢谢你的帮助!
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 个警告`
我有一个Largest接受三个参数a、b和 的函数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)
任何帮助理解和解决此错误的帮助将不胜感激。
我有一个作业,正在为它编写一个程序。我在我的程序中使用 clear() 和 getch() 函数。当我编译程序时,出现以下错误:
Fatal error: conio:no such file or directory
Run Code Online (Sandbox Code Playgroud)
我在文件的开头插入了以下行:
#include <conio>
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题。
我正在编写一个 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) 这段代码:
[selectedTagIndexes addObject: (int)sender.tag - 100];
Run Code Online (Sandbox Code Playgroud)
产生一个错误:
ARC 不允许将“int”隐式转换为“id _Nonnull”
我正在尝试从下面的 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) 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) 我有一个接口,它是和枚举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)
如何对他说“闭嘴,伙计,我知道我在做什么!”?
compiler-errors ×10
c++ ×4
java ×3
android ×1
c# ×1
class ×1
exception ×1
fatal-error ×1
objective-c ×1
return ×1
swift ×1
try-catch ×1
xcode ×1