乘法而不是指针声明 [英] Multiplication instead of pointer declaration

查看:49
本文介绍了乘法而不是指针声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有以下问题:


MyClass.h

---- -----------


class MyClass {};


此类包含在另一个头文件中的某个位置:


Foo.h

--------


#include" MyClass.h" ;


class Foo {

MyClass * bar;

}


很遗憾,这似乎不起作用。我正在使用Visual Studio

2005并且它提供了以下错误:


错误C2143:语法错误:缺少'';''之前''' *''

错误C4430:缺少类型说明符 - 假设为int。注意:C ++不支持
支持default-int

错误C4430:缺少类型说明符 - 假设为int。注意:C ++不支持
支持default-int


问题出在哪里。


关于该项目的更多事实:它是MS Windows的COM DLL使用

ATL,预编译头文件打开。


欢迎任何解决问题的方法或帮助:)


谢谢,

Stefan Weber

Hi,

I have the following problem:

MyClass.h
---------------

class MyClass {};

This class is included somewhere in another header file:

Foo.h
--------

#include "MyClass.h"

class Foo {
MyClass* bar;
}

Unfortunately, this does not seem to work. I''m using Visual Studio
2005 and it provides the following error:

error C2143: syntax error : missing '';'' before ''*''
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int

Obviously, VS does not recognize the type properly, but I can''t see
where the problem is.

Some more facts about the project: It''s a COM DLL for MS Windows using
ATL, precompiled headers are turned on.

Any solution or help to track down the problem is welcome :)

Thanks,

Stefan Weber

推荐答案

* Stefan Weber:
* Stefan Weber:




我有以下问题:


MyClass.h

----- ----------


class MyClass {};
Hi,

I have the following problem:

MyClass.h
---------------

class MyClass {};



缺少包含警卫。

Missing include guards.


此类包含在另一个头文件中的某个位置:


Foo.h

--------


#include" MyClass.h"


class Foo {

MyClass * bar;

}
This class is included somewhere in another header file:

Foo.h
--------

#include "MyClass.h"

class Foo {
MyClass* bar;
}



缺少分号。

-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?

Missing semicolon.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


缺少包括警卫。
Missing include guards.

>

[...]


缺少分号。
>
[...]

Missing semicolon.



现在,它看起来像是:


MyClass.h

---- -----------


#ifndef __MyClass_h__

#define __MyClass_h__


class MyClass {};


#endif


Foo.h

--------


#include" MyClass.h"


class Foo {

MyClass * bar;


};


然而,问题仍然存在。

Now, it looks like that:

MyClass.h
---------------

#ifndef __MyClass_h__
#define __MyClass_h__

class MyClass {};

#endif

Foo.h
--------

#include "MyClass.h"

class Foo {
MyClass* bar;

} ;

However, the problem remains.


Stefan Weber写道:
Stefan Weber wrote:

>缺少包括警卫。

[...]

缺少分号。
>Missing include guards.

[...]

Missing semicolon.



现在,它看起来像是:


MyClass.h

---- -----------


#ifndef __MyClass_h__

#define __MyClass_h__


class MyClass {};


#endif


Foo.h

--------


#include" MyClass.h"


class Foo {

MyClass * bar;


};


然而,问题仍然存在。


Now, it looks like that:

MyClass.h
---------------

#ifndef __MyClass_h__
#define __MyClass_h__

class MyClass {};

#endif

Foo.h
--------

#include "MyClass.h"

class Foo {
MyClass* bar;

} ;

However, the problem remains.



当然,问题是与你的内容无关

体验...从你显示的两个文件看来一切正常,是不是可能这个问题与其他标题有关?
br />

Zeppe

Of course, the problems were not related with what you are
experiencing... from the two files you shown everything seems ok, is it
possible that the problem is related to some other header?

Zeppe


这篇关于乘法而不是指针声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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