VisualStudio2015程序中的错误将不会运行C++; 我现在在C++类中,从书中取了一个例子,我试图通过VisualStudio 2015运行它,但是尽管没有语法错误(我可以看到),它也不会运行代码。这是我收到的错误消息

VisualStudio2015程序中的错误将不会运行C++; 我现在在C++类中,从书中取了一个例子,我试图通过VisualStudio 2015运行它,但是尽管没有语法错误(我可以看到),它也不会运行代码。这是我收到的错误消息,c++,visual-studio-2015,C++,Visual Studio 2015,我很肯定这与代码无关,但我会在下面发布代码以防万一。另外,你能一步一步地向我解释如何解决这个问题吗?因为我还不太熟悉VisualStudio界面 //Ex7_02.cpp //Creating and using boxes #include <iostream> using std::cout; using std::endl; class CBox //Class definition at global scope { publi

我很肯定这与代码无关,但我会在下面发布代码以防万一。另外,你能一步一步地向我解释如何解决这个问题吗?因为我还不太熟悉VisualStudio界面

 //Ex7_02.cpp
//Creating and using boxes

#include <iostream>
using std::cout;
using std::endl;

class CBox                      //Class definition at global scope
{
public:
    double m_Length;        //Lenght of box in inches
    double m_Width;         //Width of box in inches
    double m_Height;        //Height of box in inches
};

int main()
{
    CBox box1;                  //Declare box1 of type CBox
    CBox box2;                  //Declare box2 of type Cbox

    double boxVolume(0.0);      //Stores the volume of a box

    box1.m_Height = 18.0;           //Define the values of members of box1
    box1.m_Length = 78.0;
    box1.m_Width = 24.0;

    box2.m_Height = box1.m_Height - 10;     //Define box 2 members
    box2.m_Length = box1.m_Length / 2.0;
    box2.m_Width = 0.25*box1.m_Length;

    //Calculate volume of box1
    boxVolume = box1.m_Height*box1.m_Length*box1.m_Width;

    cout << endl << "Volume of box1 = " << boxVolume;

    cout << endl << "box2 has sides which total "
        << box2.m_Height + box2.m_Length + box2.m_Width
        << " inches.";

    cout << endl                        //Display the size of a box in memory
        << "A CBox object occupies "
        << sizeof box1 << " bytes.";
    cout << endl;
    return 0;
}
//Ex7_02.cpp
//创建和使用方框
#包括
使用std::cout;
使用std::endl;
类CBox//全局范围内的类定义
{
公众:
双m_长度;//盒子的长度(英寸)
双m_宽度;//框的宽度(英寸)
双m_高度;//盒子的高度(英寸)
};
int main()
{
CBox box1;//声明CBox类型的box1
CBox box2;//声明CBox类型的box2
double-boxVolume(0.0);//存储长方体的体积
box1.m_Height=18.0;//定义box1的成员值
box1.m_长度=78.0;
box1.m_宽度=24.0;
box2.m_高度=box1.m_高度-10;//定义框2成员
box2.m_长度=box1.m_长度/2.0;
box2.m_宽度=0.25*box1.m_长度;
//计算盒子1的体积
boxVolume=box1.m_高度*box1.m_长度*box1.m_宽度;
不能只包括以下内容:

#include "stdafx.h"
//Ex7_02.cpp
//Creating and using boxes

您的预处理器需要它作为项目选项。

您是否尝试清理并重新生成解决方案?您的消息会准确地告诉您ISSUE是什么以及如何修复它。您在窗口底部有错误消息。谷歌这些消息并查看出现了什么。项目设置为使用预编译头,但编译器找不到。So将设置更改为不使用预编译头。此处应包含任何编译器的文本或运行时错误消息,而不是微小文本的图片。非常感谢您快速简单的回复。非常有效。