C ++中的类声明

问题描述

我有一个班级: // add data if(!_instruments.TryGetValue(tick.Instrument,out var data)) _instruments.Add(tick.Instrument,data = new Data()); data.Add(tick); ... var Ohcl = _instruments[TickData.Instrument]; // example reading the data Console.WriteLine(Ohcl.High);

RTC_EXPORT定义为

public class Data
{
   private readonly Queue<Tick> _queue = new Queue<Tick>();
   public decimal High => _queue.Max(x => x.LatestPrice);
   public decimal Low => _queue.Min(x => x.LatestPrice);
   public decimal Open => _queue.LastOrDefault()?.LatestPrice ?? 0;
   public decimal Close => _queue.FirstOrDefault()?.LatestPrice ?? 0;

   public void Add(Tick tick)
   {
      _queue.Enqueue(tick);
      Update();
   }

   public void Update()
   {
      var age = DateTime.Now.AddMinutes(-5);
      while (_queue.Any() && _queue.Peek().TimeStamp < age)
         _queue.Dequeue();
   }
}

class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { ... };中的RTC_EXPORT有什么作用?

通常,我们在c ++中将类定义为#ifndef RTC_BASE_SYSTEM_RTC_EXPORT_H_ #define RTC_BASE_SYSTEM_RTC_EXPORT_H_ // RTC_EXPORT is used to mark symbols as exported or imported when WebRTC is // built or used as a shared library. // When WebRTC is built as a static library the RTC_EXPORT macro expands to // nothing. #ifdef WEBRTC_ENABLE_SYMBOL_EXPORT #ifdef WEBRTC_WIN #ifdef WEBRTC_LIBRARY_IMPL #define RTC_EXPORT __declspec(dllexport) #else #define RTC_EXPORT __declspec(dllimport) #endif #else // WEBRTC_WIN #if __has_attribute(visibility) && defined(WEBRTC_LIBRARY_IMPL) #define RTC_EXPORT __attribute__((visibility("default"))) #endif #endif // WEBRTC_WIN #endif // WEBRTC_ENABLE_SYMBOL_EXPORT #ifndef RTC_EXPORT #define RTC_EXPORT #endif #endif // RTC_BASE_SYSTEM_RTC_EXPORT_H_ 。额外的MACRO通常会做什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)