我刚刚开始学习C++,并显示代码的输出,我发现了这个方法.这在我第一次编译Programme.cpp的结构时起了作用:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它给了我一个.exe,我打开,跑了,得到了一个可爱的'Hello World!' 出现,但当我尝试编译第二个时,Variables.cpp:
#include <iostream>
using namespace std;
int main ()
{
int a, b;
int result;
a=5;
b=2;
a=a+1;
result=a-b;
cout << result;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我根本没有得到.exe,所以无法解决如何打开它.我尝试重新编译Programme.cpp的结构(删除所有相关文件后),但现在不再创建.exe了.创建的唯一文件是Programme.o和Variables.o的结构(在子目录obj\Debug中).
我能找到的唯一问题似乎是这个,但问题似乎略有不同,我尝试删除其中一个文件(因此文件夹中只有一个Programme.cpp或Variables.cpp的结构)我仍然有相同的结果.
此外,任何一个文件都没有编译器错误,我认为我没有更改程序结构中的代码块中的任何选项以及所有不起作用的程序.
谢谢,
Dalkius
编辑:构建日志:
Compiling: Structure of a Programme.cpp
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
Compiling: Variables.cpp
Process terminated with status 0 (0 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用LaTex字符串为y轴标签插入一个分数,我得到一个数字(标准字体和ylabel位置)以及我所期望的(我试图插入的分数).当我编辑代码时,这已经改变了,但是一旦我尝试调查它就停止了(当我输入时它是353.191,如果有帮助的话).如果我不尝试在y轴上添加标签,或者在没有LaTex的情况下添加标签,则该数字不存在.没有错误消息.
有问题的代码:
ylabel(text('Interpreter','LaTex',...
'string','$\frac{\tau_b(t)}{\phi \bar{U}}$',...
'FontSize',20,'position',[-1.25,0.2]));
Run Code Online (Sandbox Code Playgroud)
完整程序(上面的代码就在程序完成之前):
% --- MM3CAI Coursework 1 ---
clear all; clf('reset'); clc;
fig_num=0;
disp('Started program');
disp(' ');
% --- Task 1. About the water-brake only ---
disp('Started task 1');
disp(' ');
w_t=0.003; % Volume of water in the brake at time t [m^3]
thet_t=250; % Angular velocity of brake at time t [rads^-1]
percent=0.1; % Percent added to values for small change [%]
fraction=percent/100;
del_w=w_t*fraction;
del_t=thet_t*fraction;
w_del=w_t+del_w;
thet_del=thet_t+del_t;
clear percent fraction;
% --- …Run Code Online (Sandbox Code Playgroud)