-1
我現在處於C++類中,並從本書中拿出了一個示例,並試圖通過Visual Studio 2015運行它,但儘管沒有語法錯誤(即I可以看到)它不會運行代碼。這是我得到的錯誤消息。 VisualStudio2015程序無法運行C++
我很積極,它與代碼無關,但我會發佈下面的代碼以防萬一。另外,你可以請一步一步解釋如何解決這個問題,因爲我對Visual Studio界面還不熟悉。
//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;
}
您是否嘗試清潔和重建解決方案? – NathanOliver
你的消息告訴你到底是什麼,以及如何解決它。 – SergeyA
您在窗口底部有錯誤消息。谷歌的消息,看看會發生什麼。 – nicomp