作为 Ada 的新手,我正在探索它的语法和规则,我想提请注意接下来给出的代码。在这里,我试图设置一个变量 Actual_Stiffness 来保持一个常量值。它的价值由产品给出:
Actual_Stiffness := Stiffness_Ratio * Stiffness_Total
Run Code Online (Sandbox Code Playgroud)
其中 Stiffness_Total 已在规范文件 Material_Data.ads 中定义为常量 Long_Float,而 Stiffness_Total 的值已在广告文件中设置。
WITH Ada.Text_IO;
WITH Ada.Long_Float_Text_IO;
WITH Material_Data;
USE Material_Data;
PROCEDURE sample IS
Stiffness_Ratio : Long_Float;
Actual_Stiffness : CONSTANT Long_Float := Stiffness_Ratio * Stiffness_Total;
BEGIN -- main program
Ada.Text_IO.Put("Enter stiffness ratio: ");
Ada.Long_Float_Text_IO.Get(Item => Stiffness_Ratio);
Ada.Long_Float_Text_IO.Put(Item => Stiffness_Ratio);
--Ada.Text_IO.New_Line;
--Ada.Long_Float_Text_IO.Put(Item => Actual_Stiffness);
--Ada.Text_IO.New_Line;
--Ada.Long_Float_Text_IO.Put(Item => Stiffness_Total);
END sample;
Run Code Online (Sandbox Code Playgroud)
在编译时,我收到警告消息
警告:“Stiffness_Ratio”可能在具有值之前被引用
在运行程序时,Actual_Stiffness 没有得到正确的值。我可以将 Actual_Stiffness 定义为一个 Long_Float(不添加 CONSTANT),然后在程序中的 BEGIN 之后从产品 Actual_Stiffness := Stiffness_Ratio * Stiffness_Total 中获取它的值,此时 …
我想知道为什么Java数组声明使用大括号而不是标准括号.如图所示.我想这可能需要进一步了解大括号,但这具体到我的议程上.
Object[] tableHeaders = {"Cars","Trucks","Tacos"};
Run Code Online (Sandbox Code Playgroud)
这是正确的,而不是.
Object[] tableHeaders = ("Cars","Trucks","Tacos");
Run Code Online (Sandbox Code Playgroud) 我对 C++ 相当陌生。我在c++中遇到了两种声明成员函数的方法,即。课内和课外。我搜索了差异,它说在类中定义的函数被视为内联函数。
当我之前读到内联函数时,它指出内联只是要求编译器替换函数体而不是调用函数。但如果函数很复杂(如递归、包含静态变量、开关等),那么编译器将忽略该请求。所以即使我们在类中声明函数,如果是复杂的编译器也会忽略这个请求。那么在类外定义函数有什么意义,如果我们可以让编译器自己自动为我们做这个决定?
我想声明多个相同类型的对象,并通过一个表达式用相同的右值初始化它们;无需通过单独的语句声明和初始化它们。
我想要的是这样的:
int a = b = 10; // dummy-statement. This does not work.
Run Code Online (Sandbox Code Playgroud)
或者
int a = int b = 10; // dummy-statement. This does not work either.
Run Code Online (Sandbox Code Playgroud)
代替
int b = 10;
int a = b;
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我注意到这个涉及插入符号 (^) 字符的声明被固定在顶部的 cdecl.org 站点上:
// "cast foo into block(int, long long) returning double"
(double (^)(int , long long ))foo
Run Code Online (Sandbox Code Playgroud)
有人可以解释这里插入符号的目的是什么吗?这真的是 C 声明中的有效字符,还是某物的占位符?
我正在读一本书,在这里,给出了这样的程序-
#include<fstream>
#include<string>
#include<vector>
int main()
{
string filename; // #1
cout << "Please enter name of file to open : ";
cin >> filename;
if(filename.empty())
{
cerr << "Something...";
}
ifstream inFile(filename.c_str()); // #2
if(!inFile)
{
cerr<< "Somthing...";
}
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
并且解释段说,声明语句显示声明的位置,这是这样解释的
声明语句出现在第一次使用定义对象的地方。
我对那句话很困惑,我无法理解它的实际含义。我需要用一些例子来解释。
关于 Haskell 我不完全理解的一件事是声明函数及其类型:这是您必须做的事情还是只是为了清晰起见而应该做的事情?还是在某些情况下您需要这样做,而不是全部?
使用: symfony new my_project_nasdame --version=lts
[或者]
作曲家创建项目 symfony/网站骨架 my_project_name
[或者]
symfony 新 test_project332
PHP7.4
到处都是错误
lexcodfh@artek:~/tmp [130] $ ~/.symfony/bin/symfony new test_new_project
* Creating a new Symfony project with Composer
[KO]
Script cache:clear returned with error code 255
!!
!! Fatal error: Declaration of Symfony\Component\DependencyInjection\ServiceLocator::has(string $id) must be compatible with Psr\Container\ContainerInterface::has($id) in /home/l/lexcodfh/tmp/test_new_project/vendor/symfony/dependency-injection/ServiceLocator.php on line 46
!! Symfony\Component\ErrorHandler\Error\FatalError {#89
!! -error: array:4 [
!! "type" => 64
!! "message" => "Declaration of Symfony\Component\DependencyInjection\ServiceLocator::has(string $id) must be compatible with Psr\Container\ContainerInterface::has($id)"
!! "file" …Run Code Online (Sandbox Code Playgroud) 我一直在查看源代码,我遇到了这段代码
static char const *const delimit_method_string[] =
{
"none", "prepend", "separate", NULL
};
Run Code Online (Sandbox Code Playgroud)
我以为我知道Cconst语言中关键字的含义,但是看到这个语法后我很困惑,因为我无法解码语法的含义,所以我想知道这样使用的含义我在网上搜索了一些问题就像 stackoverflow 中的这样,const
但我仍然不明白该代码片段中语法的含义是什么,可能是因为我对C的基础知识不够好,但我真的很想改进它。
所以我写了一些代码来了解该语法是如何工作的,这就是我尝试过的:
#include <stdio.h>
int main()
{
char a = 'A';
char b = 'B';
char const * const ptr = &a;
ptr = &b;
printf("a is %c\n", *ptr);
printf("a is %c", a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到了这个输出,这在某种程度上是我所期望的。
$ gcc test.c
test.c: In function 'main':
test.c:9:13: error: assignment of read-only variable 'ptr'
9 | ptr = &b;
|
^ …Run Code Online (Sandbox Code Playgroud) declaration ×10
c ×4
c++ ×3
function ×3
constants ×2
inline ×2
ada ×1
arrays ×1
caret ×1
class ×1
curly-braces ×1
definition ×1
haskell ×1
java ×1
pointers ×1
statements ×1
symfony ×1
syntax ×1