class MyClass
{
private:
static const int intvalue= 50;
static const float floatvalue = 0.07f;
};

如上申请方式导致错误

error C2864: 'MyClass::floatvalue : only static const integral data members can be initialized within a class

1. 尝试使用 static constexpr float floatvalue = 0.5f;

error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int
error C2144: 语法错误:“float”的前面应有“;”

2.  MyClass.h

class MyClass
{
private:
static const int intvalue = 50; // can provide a value here (integral constant)
static const float floatvalue; // canNOT provide a value here (not integral)
};

MyClass.cpp

const int MyClass::intvalue; // no value (already provided in header)
const float MyClass::floatvalue = 0.07f; // value provided HERE

可以解决如上问题

博客参考 https://stackoverflow.com/questions/17566575/how-to-initialize-a-static-const-float-in-a-c-class-in-visual-studio

Visula Studio 2013 初始化静态浮点型数据在C++类内的更多相关文章

  1. Spring:注解(@suppresswarnings,@Valid,初始化静态配置数据,定时任务,@EnableAutoConfiguration)

    1.@suppresswarnings(" ") 2.@Valid @Valid注解用于校验,所属包为:javax.validation.Valid. ① 首先需要在实体类的相应字 ...

  2. Visula Studio 2013/2015自定义快捷键

    很多同学新装了VS2013/2015后, 发现快捷键变掉了, 比如之前编译快捷键是F6, 现在变成Ctrl + Shift + B, 其实要改回去很简单, 菜单Tools->Options, 打 ...

  3. visual studio 2013连接Oracle 11g并获取数据:(一:环境搭建)

    C# WinForm案例: 目标: visual studio 中点击按钮,就可获取到Oracle中数据表的内容 1.安装Visual Studio 2013 ,推荐如下网址,下载ISO镜像,一路ne ...

  4. Visual Studio 2013 Preview对C++11的支持

    为期3天的微软Build 2013大会结束了,作为微软一年一度的开发者大会,微软也做足了功夫:很多产品(包括Windows 8.1和Visual Studio 2013 Preview)发布,chan ...

  5. 在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移

    在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移 最近发布的ASP.NET MVC 5 及Visual ...

  6. Blend for Visual Studio 2013

    软件开发中为了使设计师和程序员“并行”工作并直接参与到程序的开发中来. 1.在网络程序开发团队中,草图设计后,设计师们可以使用HTML.CSS.JavaScript直接生成UI,程序员则在这个UI产生 ...

  7. Visual Studio 2013 Ultimate因为CodeLens功能导致Microsoft.Alm.Shared.Remoting.RemoteContainer.dll高CPU占用率的折中解决方案

    1.为什么Microsoft.Alm.Shared.Remoting.RemoteContainer.dll的CPU占用率以及内存使用率会那么高? 在Visual Studio 2013 Ultima ...

  8. Visual Studio 2013 Web开发

    cnbeta新闻:微软正式发布Visual Studio 2013 RTM版,微软还发布了Visual Studio 2013的最终版本..NET 4.5.1以及Team Foundation Ser ...

  9. [.net 面向对象程序设计深入](3)UML——在Visual Studio 2013/2015中设计UML活动图

    [.net 面向对象程序设计深入](3)UML——在Visual Studio 2013/2015中设计UML活动图 1.活动图简介 定义:是阐明了业务用例实现的工作流程. 业务工作流程说明了业务为向 ...

随机推荐

  1. Linux proc_mkdir和proc_create的用法

    //功能:在proc中创建一个文件夹 //参数1:创建的文件夹名称 //参数2:创建的文件夹路径,就是在哪个文件夹中创建,如果是proc根目录,此参数为NULL //返回值:创建的文件夹路径 stru ...

  2. mysql存储引擎之innodb学习

    innodb引擎特点1.支持事务:支持4个事务隔离级别,支持多版本读. 2.行级锁定(更新时一般是锁定当前行):通过索引实现,全表扫描仍然会是表锁,注意间隙 锁的影响 3.读写阻塞与事务隔离级别有关 ...

  3. js中去掉字符串中的某个指定字符

    假设一个data里面的数据是[tian,12],现在去掉[],代码如下 data=data.replace("[",""); data=data.replace ...

  4. emacs之配置etags-select

    etags-select比自带的etags定位的更好 ~/emacsConfig/etags-select-setting.el (require 'etags-select) (global-set ...

  5. waitpid()设置WNOHANG位(非阻塞模式)判断子进程的状态是否有所改变

    参考<Linux/Unix系统编程手册>26.1.5,对于系统调用waitid() #include <sys/wait.h> int waitid(idtype_t idty ...

  6. Linux c- libevent

    libevent是一个事件触发的网络库,适用于windows.linux.bsd等多种平台,内部使用select.epoll.kqueue等系统调用管理事件机制.著名分布式缓存软件memcached也 ...

  7. soap,socket

    Socket 接口是访问 Internet 使用得最广泛的方法. 如果你有一台刚配好TCP/IP协议的主机,其IP地址是202.120.127.201, 此时在另一台主机或同一台主机上执行ftp 20 ...

  8. MySQL 存储引擎、锁、调优、失误与事务回滚、与python交互、orm

    1.存储引擎(处理表的处理器) 1.基本操作 1.查看所有存储引擎 mysql> show engines; 2.查看已有表的存储引擎 mysql> show create table 表 ...

  9. IOCP的缓冲区

    IOCP的缓冲区: 应用程序的缓冲区 套接字的缓冲区 TCP的缓冲区 两个会造成WSAENOBUFS错误的原因: 锁定页面达到上限 非分页页面达到上限

  10. Rhythmk 一步一步学 JAVA (15) mybatis 入门学习-1

    1.mybatis 通过mybatis-generator-core-1.3.2 代码生成: 工具下载地址: https://code.google.com/p/mybatis/ 解压工具包 myba ...