小编jac*_*nSD的帖子

试图引用已删除的功能

我正在尝试了解fstream类,我遇到了一些麻烦.我创建了几个txt文件,一个带有笑话,另一个带有一个妙语(joke.txt)和(punchline.txt),只是为了阅读和显示内容.我向用户询问文件名,如果发现它应该打开它,清除标志然后读取内容.但我甚至无法测试它读取的内容因为我目前收到有关已删除功能的错误但我不知道我知道这意味着什么

错误1:

"IntelliSense: function "std::basic_ifstream<_Elem, _Traits>::basic_ifstream(const std::basic_ifstream<_Elem, _Traits>::_Myt &) [with _Elem=char, _Traits=std::char_traits<char>]" (declared at line 818 of "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\fstream") cannot be referenced -- it is a deleted function
Run Code Online (Sandbox Code Playgroud)

第二个错误是完全相同但是对于第二个函数(displayLastLine())

和错误3:

Error   1   error C2280: 'std::basic_ifstream<char,std::char_traits<char>>::basic_ifstream(const std::basic_ifstream<char,std::char_traits<char>> &)' : attempting to reference a deleted function
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#include "stdafx.h" 
#include <string>    
#include <iostream>  
#include <fstream>   

using namespace std; 

void displayAllLines(ifstream joke);
void displayLastLine(ifstream punchline);

 int main()          
{
    string fileName1, fileName2;
    ifstream jokeFile, punchlineFile;


    // Desribe the assigned project …
Run Code Online (Sandbox Code Playgroud)

c++ string fstream function ifstream

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

从VS中的Test Explorer获取测试列表

这是一种"高级"/简单的问题.我正在尝试获取VS2012中我的测试资源管理器中填充的所有测试的列表.我想将它与测试列表进行比较,我想知道是否有任何方法可以从测试资源管理器中获取所有名称,例如复制/粘贴,导出到csv或任何此类性质.

testing coded-ui-tests visual-studio-2012 test-explorer

9
推荐指数
2
解决办法
2957
查看次数

功能将日期显示为YYYY-MMM

正如标题所述,我正在尝试制作一个小函数来获取数据库中已有的日期值并将其显示为YYYY-MMM(例如:2013年11月).SQL Server.我试过DatePart,但它一次只需要一部分争论(不能做YYYY-MMM).有任何建议将其作为一项功能吗?

Create function fnYearMonth
(@InputDate date)
returns date
Begin
Return DatePart(YYYY-MMM, @inputdate)
End;

Select hiredate, dbo.fnYearMonth(hiredate) as ReviewDate
from employees
Order by ReviewDate 
Run Code Online (Sandbox Code Playgroud)

sql sql-server scalar user-defined-functions date-formatting

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

如果我有两个接口,一个类可以继承两个接口吗?

我有一个有 2 个接口的类,我有一些带有子类的超类,我希望超类继承这两个接口。如果我只是引用接口所在的类,它会起作用吗?即超类:我的接口

这是带有接口的类

public class Myinterfaces
{
    public interface IBakeable
    {
        int OvenTemp { get; }
    }

    public interface IAccounting
    {
       int Cost { get; }
    }

    public enum Colors
    { 
        red = 1,
        blue,
        yellow
    }
}
Run Code Online (Sandbox Code Playgroud)

这是超类的一个例子

public class CeramicsSuperClass : Myinterfaces
{
    public string ItemName { get; set; }
    public int Cost { get; set; }
    public int OvenTemp { get; set; }
}
public class Vases : CeramicsSuperClass
{
    private int _BaseDiam;
    public Vases(int diam) …
Run Code Online (Sandbox Code Playgroud)

c# inheritance interface subclass superclass

2
推荐指数
1
解决办法
1749
查看次数

无法在数组C++中找到最高/最低元素

我是C++的新手,只有C#,Python和JS的经验所以请耐心等待!

我将用户输入的5个分数存储在一个数组中.我关闭数组并评估数组中的分数以找到最低值和最高值.我需要删除这两个,然后找到其他3个值的平均值.我的问题是,我没有找到最高/最低价值.我在findLowest()和findHighest()中有逻辑,但为了测试它我在main()中放置相同的逻辑,以查看它在传递之前是否正常工作,并且它不起作用.有人可以指导我找到阵列中的最高/最低值吗?谢谢!

#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

void getJudgeData(double score)
{
    cin >> score;
    if (score > 10 || score < 0)
    {
        cout << "Invalid score, please enter again." << endl;
        cin >> score;
    }
    else
    {
    cout << "Thank you." << endl;
    }
}

double findLowest(double scores[])
{
    double lowScore = *min_element(scores, scores+5);

    return lowScore;
}

double findHighest(double scores[])
{
    double highScore = *max_element(scores, scores+5);

    return highScore;
}
double calcScore(double …
Run Code Online (Sandbox Code Playgroud)

c++ arrays function

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

保存txt文件到错误的位置

我正在尝试将文本文件日志保存到Windows窗体项目中的特定位置.我设置InitialDirectoryPath.GetFullPath(filePath)其中我通过在filePath被设置为一个简单的路径"C:\MyWork\EventLogs\"

日志保存在程序的退出(当用户关闭或点击退出按钮时),但它仍然保存在Project\bin\Debug我的项目的文件夹中.

任何想法都会很棒.谢谢!

try
{
    DateTime today = DateTime.Now;
    string todayDate = today.ToString("yyyy-MM-dd_HHmm");
    string fileName = (todayDate + "_EventLog" + ".txt").Trim();
    string filePath = @"C:\MyWork\EventLogs\";
    DirectoryInfo di = Directory.CreateDirectory(filePath);
    SaveFileDialog sn = new SaveFileDialog
    {
        FileName = fileName,
        AddExtension = true,
        CheckPathExists = true,
        Filter = "Text (*.txt)|*.txt",
        OverwritePrompt = true,
        InitialDirectory = Path.GetFullPath(filePath)
    };

    sn.RestoreDirectory = true;
    StreamWriter SaveFile = new StreamWriter(fileName);
    foreach (var item in EventLog)
    {
        SaveFile.WriteLine(item);
    } …
Run Code Online (Sandbox Code Playgroud)

c# streamwriter savefiledialog winforms

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

一个开关中的默认语句,在while循环中,没有破坏c#

基本的纸牌游戏,在while循环中有一个switch语句.case是用户输入选择的卡号,然后更换.那部分工作正常.但测试默认语句(任何数字不是0-5),它进入默认的console.writeline的无限循环,我不知道为什么它没有破坏.在以前的开关嵌套在while循环中它对我有效,但我从来没有在以前的默认值之前有这个无限循环问题.任何帮助/提示?

int userInput;
string userString;
Console.WriteLine("Would you like to replace a card?");
Console.WriteLine("Select which card you would like to replace, 1-5. Enter 0 to skip");
userString = Console.ReadLine();
int.TryParse(userString, out userInput);
while (userInput != 0)
{
    switch (userInput)
    {
        case 1:
            userInput--;
            userHand[userInput] = cardDeck.GetOneCard();
            break;
        case 2:
            userInput--;
            userHand[userInput] = cardDeck.GetOneCard();
            break;
        case 3:
            userInput--;
            userHand[userInput] = cardDeck.GetOneCard();
            break;
        case 4:
            userInput--;
            userHand[userInput] = cardDeck.GetOneCard();
            break;
        case 5:
            userInput--;
            userHand[userInput] = cardDeck.GetOneCard();
            break;
        default:
            Console.WriteLine("Incorrect input, try again");
            break; …
Run Code Online (Sandbox Code Playgroud)

c# default infinite-loop while-loop switch-statement

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