小编che*_*zer的帖子

C++难以理解的编译错误

我有一个非常简单的任务要做.写一个定义时间的类.出于某种原因,在其中一个函数中我得到一个错误,我不明白.
我搜索了一个没有成功的解决方案,所以最后我决定将它发布在这里.

time.h中

class time
{
private:
    int _hours;
    int _minutes;
    float _seconds;
    bool checkHours(int hours);
    bool checkMinutes(int minutes);
    bool checkSeconds(float seconds);

public:

time(int hours=0, int minutes=0, float seconds=0);
time(const time & tm);
~time();


void hours(int hours);
int  hours() const;
void minutes(int minutes);
int  minutes() const;
void seconds(float seconds);
float  seconds() const;


void operator=(time tm);
bool operator==(time tm);


void print();
time getTimeFromUser();
float getTimeAsFractionOfTheDay(time tm);
Run Code Online (Sandbox Code Playgroud)

};

time.cpp

#include <iostream>
#include "time.h"

bool time::checkHours(int hours)
{
    return hours>=0 && hours<24; …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors

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

C# HttpClient 文件流内容错误的边界头

我正在尝试像浏览器(chrome)一样模拟 HTTP 发布文件:

HTML :

<form name="fnup" method="post" action="action.shtml" enctype="multipart/form-data">    
         <input name="firmfile" id="firmfile" type="file">
         <input type="submit" id="firmbutton" value="Upgrade" class="othsave">
</form>
Run Code Online (Sandbox Code Playgroud)

C#

     public async Task<string> UploadFile(string actionUrl, string filePath)
            {
                var httpClient = new HttpClient();
                //Should I need to add all those headers??? it will help me? what is necessary?
                httpClient.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1");
                httpClient.DefaultRequestHeaders.Add("Origin", "http://" + ip);
                httpClient.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1");
                httpClient.DefaultRequestHeaders.Add("Pragma", "no-cache");
                httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
                httpClient.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
                httpClient.DefaultRequestHeaders.Add("Referer", "http://" + ip + …
Run Code Online (Sandbox Code Playgroud)

html c# post http http-headers

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

AngularJS在指令模板中使用canvas

我正试图通过canvas使用来实现进度条directive.
我是elrady通过JS对象实现这个控件

这是非角度的方式:

function progressBar(id,contentDiv)
{
    this.id = id;
    this.height = 2;
    this.width = 200;
    this.backColor = "#383838";
    this.foreColor = "#61650c";
    this.value = 0;
    this.context = null;
    this.backToZero = true; 

    this.create = function ()
    {
        var str = "";
        str += "<div class='progressBarDiv' id='" + this.id + "' style='width: " + this.width + "px;'>";
        str += "<canvas id='canvas_" + this.id + "' class='progressBarCanvas' width='" + this.width + "' height='" + this.height + "' style='width: " + …
Run Code Online (Sandbox Code Playgroud)

javascript canvas angularjs angularjs-directive

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

CSS - 覆盖 div 高度:100% 包括滚动区域不起作用

我正在尝试做一些非常简单的事情。
我有div滚动,我希望覆盖 div 将覆盖所有高度包括滚动区域。我试过min-height:100%(就像在这个问题中一样)但它不起作用。

这是一个例子https://jsfiddle.net/svfukxjd/2/

.main {
  height: 300px;
  width: 150px;
  background: red;
  overflow: auto;
  position: relative;
}
.cover {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  bottom: 0;
  background: green;
  opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)
<div class="main">
  <div>
    Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
    <br>Test
  </div>
  <div class="cover">

  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css overlay overflow scrollbar

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

C#交换服务器获取会议室约会列表

我正在尝试EWS Managed API获取会议室列表,并为每个房间查看一周的约会列表。

我看到在Exchange使用EWS取得房间列表通过在Exchange使用EWS获得约会和会议

我测试了第一个链接,得到0个房间。
同样对于第二个链接,它给了当前用户日历,但没有开会。

我需要三件事:

1)获取我组织中的会议室列表。
2)获取每个房间的会议日历(X天)。
3)对于每次会议,由谁组织会议。

我找不到用于获取此信息的API。

c# exchange-server exchange-server-2007 exchangewebservices exchange-server-2010

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

Nestjs Config 访问引导级别的配置

根据此文档, 您在 AppModule 中导入您的配置。
我正在尝试访问我的 main.ts 文件中引导程序级别的配置。像这样的东西:

const app = await NestFactory.create(AppModule);
  if (config.get('swagger.enabled'))
  {
    initSwagger(app);
  }
  await app.listen(8080);
Run Code Online (Sandbox Code Playgroud)

在这一点上我无权访问配置的问题,只有其他模块才能访问这样的配置:

@Injectable()
export class SomeService {
    constructor(private readonly httpService: HttpService,
                  private readonly config: ConfigService) {}
}
Run Code Online (Sandbox Code Playgroud)

我的问题:如何在引导程序级别访问“nestjs-config”

nestjs nestjs-swagger nestjs-config

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

C# AutoMapper - 如果源中不存在,则在 dest 属性中设置默认值

我有:

Class A
{
    public string FirstName { get; set; }
}

Class B
{
    public string FirstName { get; set; }
    public Guid RequestId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我要地图从A到B,因为“A”具有RequestId我想将它设置为Guid.NewGuid()

我试过这个代码:

var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap<A, B>().ForMember(m => m.RequestId, o => Guid.NewGuid());
            
            });
            _mapper = config.CreateMapper();
Run Code Online (Sandbox Code Playgroud)

但是我在 RequestId 中仍然得到空的Guid。

c# guid automapper

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

JavaScript - 检查的最佳做法是功能

我在调用之前看到了很多种用于检查回调函数的方法.

1)

 function(callBack)    
      {    
           ...
           if(callBack != null)
              callBack();   
      }      
Run Code Online (Sandbox Code Playgroud)

2)

  function(callBack)    
          {    
               ...
               if(typeof callBack == 'function')
                  callBack();   
          }  
Run Code Online (Sandbox Code Playgroud)

3)

  function(callBack)    
          {    
               ...
               if(callBack !== null)
                  callBack();   
          } 
Run Code Online (Sandbox Code Playgroud)

4)

  function(callBack)    
          {    
               ...
               if(callBack != undefined)
                  callBack();   
          }
Run Code Online (Sandbox Code Playgroud)

5)

   function(callBack)    
          {    
               ...
               try{    
                  callBack();  
                  } catch(err) {}

          }
Run Code Online (Sandbox Code Playgroud)

6)

   function(callBack)    
          {    
               ...
                if (callBack && typeof(callBack) == "function")
                  callBack();   

          }
Run Code Online (Sandbox Code Playgroud)

7)

    function(callBack)    
          {    
               ...
                if(callBack)
                  callBack();   

          }
Run Code Online (Sandbox Code Playgroud)

8)

    function(callBack)    
              {    
                   ...
                    if(typeof window[callBack] === 'undefined')
                      callBack();   

              }
Run Code Online (Sandbox Code Playgroud)

9)

  function(callBack)    
              { …
Run Code Online (Sandbox Code Playgroud)

javascript callback

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

将 int 转换为十六进制格式 0xyy c#

我需要编写一个函数,它接收一个类型int(十进制)的参数,并返回string包含十六进制 int 值,但格式为 0xyy
不仅如此,我还希望答案采用 4 字节的固定格式,例如:

int b = 358;
string ans = function(b); 
Run Code Online (Sandbox Code Playgroud)

在这种情况下 ans = "0x00 0x00 0x01 0x66"

int a = 3567846; 
string ans = function(a);
Run Code Online (Sandbox Code Playgroud)

在这种情况下 ans = "0x00 0x36 0x70 0xE6"

c# hex

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