直到前一段时间,我认为.a静态库只是.o目标文件的集合,只是归档它们而不是以不同的方式处理它们.但是链接到.o对象并链接到包含此.o对象的.a静态库显然是不一样的.我不明白为什么......
我们来考虑以下源代码文件:
// main.cpp
#include <iostream>
int main(int argc, char* argv[]) {
std::cout << "main" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
// object.hpp
#include <iostream>
struct Object
{
Object() { std::cout << "Object constructor called" << std::endl; }
~Object() { std::cout << "Object destructor called" << std::endl; }
};
Run Code Online (Sandbox Code Playgroud)
// object.cpp
#include "object.hpp"
static Object gObject;
Run Code Online (Sandbox Code Playgroud)
让我们编译并链接并运行以下代码:
g++ -Wall object.cpp main.cpp -o main1
./main1
> Object constructor called
> main
> Object destructor called
Run Code Online (Sandbox Code Playgroud)
构造函数是全局gObject对象的析构函数.
现在让我们从代码中创建一个静态库,并在另一个程序中使用(链接)它:
g++ …Run Code Online (Sandbox Code Playgroud) 我想允许我的用户为其活动设置时间表。可能是一天,或者为了方便起见,我希望允许他们指定重复发生的事件(类似于 Outlook 约会)。
对于单个事件,这似乎很简单(伪代码):
只需有一个包含日期的 DateOfEvent 列即可。
要获取未来事件:
从 DateOfEvent > {DateTime.Now} 的事件中选择 *
但是我如何存储和查询重复发生的事件呢?我不需要做时间,因为我只需单独存储它,如果他们需要不同的时间,我只需让他们创建另一个事件。所以不:每周三 5 点和周四 3 点。
例子:
每个周一、周二、周三、周四、周五、每周
每周每个星期三
每个月的第二个星期二
我曾经查询过什么
我添加了开始日期和结束日期。如果用户选择了单个日期,我将开始日期和结束日期都设置为所选日期。我只需稍微修改一下答案的代码。
DECLARE
@StartDate SMALLDATETIME,
@EndDate SMALLDATETIME;
SELECT
@StartDate = '20091129',
@EndDate = '20101220';
SELECT
d.CurrentDate,
m.*
FROM
Calendar AS d
INNER JOIN Meet AS m
ON
(
(d.CurrentDate = m.StartDate AND d.CurrentDate = m.EndDate)
OR d.DaysOfTheMonth = m.DayOfTheMonth
OR (d.DaysOfTheWeek = m.DayOfTheWeek AND COALESCE(m.WeekOfTheMonth, d.WeekOfTheMonth) = d.WeekOfTheMonth)
OR d.DaysOfTheWeek IN (1,7) AND m.OnWeekends = 1
OR …Run Code Online (Sandbox Code Playgroud) 我想在地图中显示注释.我有字符串格式的lat和longi.现在我只需将其转换为int.
NSString *s= @"18.65799";
location1.latitude =[s intValue];
NSLog(@"1%d",[s intValue]);
NSString *s1= @"73.774262";
location1.longitude=[s1 intValue];
Run Code Online (Sandbox Code Playgroud)
但是当我显示[s intValue]时,输出为118. NSLog的输出(@"1%@",location1.latitude)为空;
请帮忙.
我想创建自己的类扩展int数组.那可能吗?我需要的是可以通过"+"运算符添加到另一个数组(每个元素添加到每个数组)的int数组,并通过"=="进行比较,因此它可以(希望)用作字典中的键.
问题是我不想为我的新类实现整个IList接口,而只是将这两个运算符添加到现有的数组类中.
我正在尝试做这样的事情:
class MyArray : Array<int>
Run Code Online (Sandbox Code Playgroud)
但它显然没有这样做;).
对不起,如果我不清楚,但我现在正在寻找解决方案几个小时...
更新:
我试过这样的事情:
class Zmienne : IEquatable<Zmienne>
{
public int[] x;
public Zmienne(int ilosc)
{
x = new int[ilosc];
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return base.Equals((Zmienne)obj);
}
public bool Equals(Zmienne drugie)
{
if (x.Length != drugie.x.Length)
return false;
else
{
for (int i = 0; i < x.Length; i++)
{
if (x[i] != drugie.x[i])
return false;
}
} …Run Code Online (Sandbox Code Playgroud) 我的第一个问题是,是否可以将泛型类型指定为参数,其次,是否可以使用下面列出的伪代码?
我假设它将使用.net 4.0和动态修饰符,但我对4.0之前的解决方案更感兴趣.
public static void SomeMethod(List<T> l, Type type, Control samplecontrol)
{
l.Add((type)samplecontrol);
}
Run Code Online (Sandbox Code Playgroud)
编辑:
这是我的解决方案......
public static void FindControlRecursive<T>(Control parent, List<T> l)
{
foreach (var ctrl in parent.Controls)
{
if (ctrl.GetType() == typeof(T))
l.Add((T)ctrl);
if (((Control)ctrl).Controls != null && ((Control)ctrl).Controls.Count > 0)
foreach (Control _ctrl in ((Control)ctrl).Controls)
FindControlRecursive<T>(_ctrl, l);
}
}
Run Code Online (Sandbox Code Playgroud) 根据标题.
我有以下代码创建二叉搜索树,但如果我想用用户输入动态创建和更改,如果我不能在haskell中更改变量的值,我该怎么做?!?
find :: (Ord a) => Node a -> a -> Bool
find (Node val left right) s
| s == val = True
| s < val = find left s
| s > val = find right s
find Empty s = False
data Node a = Node a (Node a) (Node a)
| Empty
myTree = Node "m" (Node "a" Empty Empty)
(Node "z" Empty Empty)
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我有这样一张桌子:
+-----+-----+-------+
| id | fk | value |
+-----+-----+-------+
| 0 | 1 | peter |
| 1 | 1 | josh |
| 3 | 2 | marc |
| ... | ... | ... |
Run Code Online (Sandbox Code Playgroud)
我现在想要获得具有多个值的所有条目.预期结果将是:
+-----+-------+
| fk | count |
+-----+-------+
| 1 | 2 |
| ... | ... |
Run Code Online (Sandbox Code Playgroud)
我试图像这样实现:
select fk, count(value) from table where count(value) > 1;
Run Code Online (Sandbox Code Playgroud)
但甲骨文并不喜欢它.
所以我试过这个......
select * from (
select fk, count(value) as cnt from table
) …Run Code Online (Sandbox Code Playgroud) var fu1 = document.getElementById("FileUpload1");
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得fileupload控件的文件名 id FileUpload1
我有一个批处理文件test.bat来启动一个PowerShell脚本:
@pushd "C:\myscripts"
powershell .\test.ps1 arg1 "arg2 with space" arg3
@popd
Run Code Online (Sandbox Code Playgroud)
脚本test.ps1(位于C:\ myscripts)是一个非常简单的脚本:
# just print out the arguments
Write-Output ("args count: {0}" -f $args.length)
$args
Run Code Online (Sandbox Code Playgroud)
然后我尝试启动test.bat.我应该将三个参数传递给ps1,但我得到以下结果:
args count:5 arg1 arg2,空格arg3
我在脚本中的预期,args [0]应该是arg1和args [1]应该是"arg2 with space"而args3 [2]应该是arg3.我无法理解为什么脚本实际上得到5个参数.
如何将cmd或batch中的参数传递给powershell,就像我预期的那样?像这样:
args count: 3
arg1
arg2 with space
arg3
Run Code Online (Sandbox Code Playgroud) c# ×4
arrays ×1
asp.net ×1
c++ ×1
constants ×1
date ×1
file-upload ×1
g++ ×1
generics ×1
group-by ×1
haskell ×1
having ×1
iphone ×1
javascript ×1
linker ×1
linq-to-xml ×1
list ×1
operators ×1
oracle ×1
powershell ×1
scheduling ×1
sql ×1
sql-server ×1
variables ×1
xml ×1