缺少类型说明符 - 假设为int。注意:C ++不支持default-int [英] missing type specifier - int assumed. Note: C++ does not support default-int

查看:148
本文介绍了缺少类型说明符 - 假设为int。注意:C ++不支持default-int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  const  Timer1 =  1 ; 
const Timer2 = 2 ;
const ID_TOOLTIP = 1 ;



由Vc ++运行这些类型的错误发生在如何解决这类问题....

解决方案

你必须指定一种类型(或者,相当现代编译器,您可以使用自动 [ ^ ]说明符),例如

  const   int  Timer1 =  1 ; 







  const   auto  Timer1 =  1 ; 


我将扩展您尝试做的回答2件事中的一件



1。)只需提供静态常数numbe你几乎没有变过你很少给你一个名字,所以它读得很好,你可以停止输入数字或在需要时全局更改它。



假设在C / C ++中使用#define

  #define Timer1 1 
#define Timer2 2
#define ID_TOOLTIP 1





这不会被编译器解释为直接文本替代,只要它看到它替换第二个的初始语句然后实际运行编译。实际值在最终代码中的内存中不存在,并且您注意到它没有行结尾;声明,因为它是文本替换。



2。)提供物理上存在于内存地址但不变的内容。

如果你有一个类似于将要反复使用的表的东西,那么在内存中使它成为常量是有道理的。



假设你使用表格

 const< type> < label> =< value>; 



所以它看起来像

 const int Timer1 = 1; 
const int Timer2 = 2;
const long ID_TOOLTIP = 1;



由于ID_TOOLTIP我怀疑你想要上面的数字1表格,因为工具提示,buttonid,子窗口id往往只是#已定义


您正在声明3个变量而不告诉编译器它们的类型是什么...

试试这个(或任何其他类型适合您的应用程序):

  const    int   Timer1 =  1 ; 
const int Timer2 = 2 ;
const int ID_TOOLTIP = <1 /跨度>;


const Timer1 = 1;
const Timer2 = 2;
const ID_TOOLTIP = 1;


Run by Vc++ these type of error occur how to solved this kind of problem ....

解决方案

You must specify a type (or, by a rather modern compiler, you are allowed to use the auto[^] specifier), e.g.

const int Timer1 = 1;



or

const auto Timer1 = 1;


I am going to extend the answer you trying to do 1 of 2 things

1.) Just provide a static constant number which you rarely if ever gets changed and you are giving it a name so it reads well and you can stop typing the number or change it globally if required.

Assuming that you use #define in C/C++

#define Timer1 1
#define Timer2 2
#define ID_TOOLTIP 1



Not this gets interpreted by the compiler as a straight text substitute anywhere it sees the initial statement it substitutes the second and then it actually runs the compilation. The actual value does not exist anywhere in memory in the final code and you note it has no line ending ";" statement because it is a text substitution.

2.) Provide something that physically exists in memory address but is constant.
If you have something like a table that is going to be used over and over then making it a constant in memory makes sense.

Assuming that you use the form

const <type> <label>=<value>;


So it looks like

const int Timer1=1;   
const int Timer2=2;
const long ID_TOOLTIP=1;


Due to the ID_TOOLTIP I suspect you want number 1 form above because tooltip, buttonid,child window id's tend to be just #defined


You are declaring 3 variables without telling the compiler what their type is...
Try this (or any other type suits your application):

const int Timer1 = 1;
const int Timer2 = 2;
const int ID_TOOLTIP = 1;


这篇关于缺少类型说明符 - 假设为int。注意:C ++不支持default-int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆