为什么这个程序不能在VC++2008Express中编译?
Why doesn't this program compile in VC++2008Express?
此程序可在tc++ 3.0上编译和运行。
为什么这个程序不能在vc++ 2008Express中编译?
#include <iostream>
using namespace std;
class MyClass
{
private:
class MyNestedClass
{
private:
int myInteger;
public:
MyNestedClass(int a)
{
myInteger = a;
}
void Show()
{
cout<<myInteger;
}
};
};
int main()
{
MyClass::MyNestedClass myNestedClassObject(100);
myNestedClassObject.Show();
}
显示以下消息:
1>------ Rebuild All started: Project: Test, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Test', configuration 'Debug|Win32'
1>Compiling...
1>Static_Data_Member.c
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(39) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(39) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(41) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(42) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(43) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(44) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(45) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(46) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(47) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(48) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(49) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(49) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(49) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(49) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(50) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(50) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(50) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(50) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(51) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(52) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(53) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(54) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(55) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(56) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdio(56) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(21) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : error C2059: syntax error : ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:program filesmicrosoft visual studio 9.0vcincludecstdlib(23) : fatal error C1003: error count exceeds 100; stopping compilation
1>Build log was saved at "file://h:TestDebugBuildLog.htm"
1>Test - 102 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
这是一个c++程序,但是你给源文件的扩展名为。C。
默认情况下,Visual c++编译器将。C文件编译为C文件。使用。cpp扩展名或使用/TP标志编译可将源文件编译为c++。
然而,即使将源代码编译为c++,程序仍然无效。MyNestedClass
是MyClass
的私有成员类型,所以不能在main()
中构造它的实例。
相关文章:
- 参考资源文件VC++中的$(SolutionDir)
- VC++本机单元测试,找不到调试符号
- 在这里,当我们比较 if(vc[i]==vc1[i]) 时,它是向量数组. 实际上比较的值是多少,
- VS2015 中的 VC++ 目录
- VS2015/VC++ 在新类模板中禁用默认 #include "stdafx.h"
- 如何解释 #if/#else 位域?(VC++菜鸟)
- 双线程应用比单线程应用慢 C++ (VC++ 2010 Express).如何解决?
- 使用线程 C# 中的 VC++ 6.0 COM DLL
- wcscpy 在 g++ 和 vc++ 中的不同行为
- STL 向量无缘无故损坏,VC++ 2017
- VC++ wcscpy_s随机断言"Buffer is too small"
- 意外的模板与VC++中的std::void_t匹配
- 使用外部依赖项运行 VC++ 单元测试时"Failed to set up execution context"
- Microsoft VC++, vsnprintf, and Pipes (IO) Bug
- 如何打开和读取16位.raw文件Vc++(Wince 平台)
- 在Visual Studio 2017上使用VC++ 2015工具链时缺少ATL标头
- VC++ 代码中的ERROR_INVALID_PARAMETER和ERROR_CONNECTION_INVALID
- Boost tread 代码在 VC++ 下编译,但不在 GCC 下编译:如何获得更好的调试信息
- Qt安装程序框架:检测是否安装了VC++可再发行组件
- 为什么这个程序不能在VC++2008Express中编译?