我有这个代码:
#include <stdio.h>
int getAns(void);
int num;
int main()
{
int (*current_ans)(void);
current_ans = &getAns;
// HERE
printf("%d", current_ans());
}
int getAns()
{
return num + 3;
}
Run Code Online (Sandbox Code Playgroud)
但是,是否有可能在// HERE现场允许下一行以printf("%d", current_ans);环形方式访问getAns()?
我喜欢把自己与语法事物混淆,而不是专注于真正做事.:)
我知道我能用这件事做些什么,但我仍然想知道幕后真正发生了什么.
所以...我只是想知道将括号内的字符串放入有意义的原因和情况是什么.我看到一种返回类似的方法
return (string1 + " " + string2);
Run Code Online (Sandbox Code Playgroud) 我在Emacs 23工作,通过AUCTeX编辑LaTeX.我在emacs中注意到,当我按下时C-c },我收到了迷你消息
扫描错误:"不平衡括号",16026,16440
问题1.这个命令到底是做什么的?
问题2.更一般地说,我如何确定给定宏的作用?例如,是否有一个通用命令请求键盘快捷键作为输入并输出该快捷键绑定到的命令的描述?是否有所有活动键盘快捷键的列表?
问题3.如何找到无与伦比的括号?这里的帖子推荐命令M-x check-parens,但它没有任何帮助,甚至没有迷你消息.
我看过多个教程,显示C#方法的创建,括号包含参数或简单为空.我还看到了用括号写的C#方法.
public int Value {
get{ return _Value; }
set{ _Value = value; }
}
Run Code Online (Sandbox Code Playgroud)
我还没有测试过该代码,但这是允许的吗?这被认为是不好的形式吗?
假设我有一个字符串,如:
abc(def(gh)il(mn(01))afg)lmno(sdfg*)
Run Code Online (Sandbox Code Playgroud)
如何确定第一个的匹配括号?(意思(def(gh)il(mn(01))afg))
我试图通过计算开放括号的数量直到第一个')'来创建一个between函数,但它不适用于像这样的字符串.
如何在用parantheses('if'或'for'-loop)包围的范围中设置结果变量.结果是正确的(>> RESULT:aaa = bbb),直接调用过程,并且在for循环或if语句中使用时失败(>> RESULT:ccc =).
:: =====================================
@setlocal
@echo off
@rem (1)
call :testReturn aaa
echo RESULT: aaa = %aaa%
@rem (2)
if "1" == "1" (
call :testReturn ccc
echo RESULT: ccc = %ccc%
)
goto :eof
:testReturn
set %~1=bbb
exit /b
endlocal
Run Code Online (Sandbox Code Playgroud)
谢谢!!
我遇到了一个自执行函数,它在声明包含var的条件下执行,如果它不存在则传递一个对象.
例:
var myFunc = (function(myFunc){}(myFunc || {}));
Run Code Online (Sandbox Code Playgroud)
为什么有一个"或"条件运算符传递一个对象?
我在一种方法中有这样的东西
autoPtr<LESModel> LESModel::New
95 (
96 const volVectorField& U,
97 const surfaceScalarField& phi,
98 transportModel& transport,
99 const word& turbulenceModelName
100 )
101 {
...
122 dictionaryConstructorTable::iterator cstrIter =
123 dictionaryConstructorTablePtr_->find(modelType);
...
143 return autoPtr<LESModel>
144 (
145 cstrIter()(U, phi, transport, turbulenceModelName)
146 );
147 }
Run Code Online (Sandbox Code Playgroud)
如果我是对的cstrIter是类的变量dictionaryConstructorTable::iterator(虽然找不到这个类)并且从第143行开始,autoPtr<LesModel>调用构造函数并返回结果.autoPtr<LESModel>因此,构造函数之后的括号应该是参数,因为cstrIter是一个变量,我想知道变量之后的两个括号是什么意思.也许我误读了什么?
我正在尝试使用折叠和追加字节串操作.请参阅下面的代码.
import qualified Data.ByteString.Char8 as C
selectSource :: [String] -> C.ByteString
selectSource xs = C.append (foldl addSource emptySource xs) (C.pack "<head>")
Run Code Online (Sandbox Code Playgroud)
addSource并相应emptySource地定义.用括号看起来有点难看,我想在selectSource函数中删除它们
C.append $ foldl addSource emptySource xs $ C.pack "<head>"
Run Code Online (Sandbox Code Playgroud)
但没有这样做,并得到一个错误消息说
Couldn't match expected type ‘C.ByteString -> C.ByteString’
with actual type ‘C.ByteString’
The first argument of ($) takes one argument,
but its type ‘SourceByteString’ has none
In the second argument of ‘($)’, namely
‘foldl addSource emptySource [] $ C.pack "<head>"’
Run Code Online (Sandbox Code Playgroud)
这有效
C.append (foldl addSource …Run Code Online (Sandbox Code Playgroud) 我正在分析分析一些第三方代码,并且有一个看起来像这样的"懒惰"var语句,我想了解括号在"计算属性"花括号之后做了什么:
lazy var defaults:NSUserDefaults = {
return .standardUserDefaults()
}()
Run Code Online (Sandbox Code Playgroud)
"return .standardUserDefaults()"正在返回NSUserDefaults实例对象,那么为什么要在右花括号后面添加一个()?
谢谢
parentheses ×10
haskell ×2
batch-file ×1
c ×1
c# ×1
c++ ×1
constructor ×1
emacs ×1
emacs23 ×1
function ×1
java ×1
javascript ×1
macros ×1
methods ×1
oop ×1
pointers ×1
scope ×1
string ×1
swift ×1
windows ×1