m*****j 发帖数: 499 | 1 eclipse似乎把这个namespace的声明当成element的属性了,还提示应该在dtd里声明这
个属性。这个是正常的吗? |
|
t****t 发帖数: 6806 | 2 OK, solved. let me explain this, this is complex.
you called copy(....begin(), ....end(), ostream_iterator<...>(...)), so
ostream_iterator will do the << for you. naturally, ostream_iterator is
within namespace std, so operator<< is called in namespace std.
Now for overload resolution. there are a lot of operator<< within namespace
std; so these are considered. your parameters to operator<< are std::basic_
ostream<...> and std::pair<...>, they are both in namespace std. Therefore
no other namesp... 阅读全帖 |
|
x******a 发帖数: 6336 | 3 I got thousands problems on the following piece of code "dumpfile.h" when I
compile under cygwin. it is ok under visual stduio... can anyone help?
Thanks!
#include
#include
#include //ostream_iterator
#include //cerr
#include //std::copy
template
void dump_to_file(const char* filename, const std::vector& v_d){
std::ofstream ofs(filename);
if(!ofs){
std::cerr<<"Unable to open the file to write!n";
return ;... 阅读全帖 |
|
A*******e 发帖数: 2419 | 4 下面两种写法,定义Alias的位置语义上有区别吗?Alias都只是foo.cc里可见吧?
foo.cc
using Alias = namespace_x::Alias
namespace foo {
namespace {
// some code using Alias
} // namespace
// some other code using Alias
} // namespace foo
vs
foo.cc
namespace foo {
namespace {
using Alias = namespace_x::Alias
// some code using Alias
} // namespace
// some other code using Alias
} // namespace foo |
|
h*****g 发帖数: 312 | 5 namespace {static int n;}
namespace A{
namespace {static int n}
}
using namespace A;
int main()
{
n = 5;
return 0;
};
Referring to the sample code above, which one of the following statements is
true?
A.
There is nothing wrong with the sample code.
B.
Unnamed namespaces are illegal.
C.
Nested namespaces are illegal.
D.
Nested namespaces that are unnamed are illegal.
E.
The reference to n is ambiguous.
此题为啥选E? |
|
w***g 发帖数: 5958 | 6 自己动手试了一下,发现用下面的方法可以解决这个问题。
#include
using namespace std;
class A {
};
namespace n1 {
const A& operator ++ (A &a) {
cout << "n1" << endl;
return a;
}
}
namespace n2 {
const A& operator ++ (A &a) {
cout << "n2" << endl;
return a;
}
}
using namespace n1;
using namespace n2;
int main ()
{
A a;
n1::operator ++(a);
n2::operator ++(a);
return 0;
} |
|
g****y 发帖数: 436 | 7 请问下面MAPPER的type应该如何写?先谢过了!
//hist_helper.h
namespace hist_aux {
template<
typename C,
typename T,
typename MAPPER
>
void getHist(const T& vals,
MAPPER pf,
C& res) {
typename T::const_iterator it;
for (it = vals.begin(); it != vals.end(); ++it) {
res.at(pf(*it))++;
}
}
} /* namespace hist_aux */
namespace hist{
class Hist {
public:
// ctr & dtr
// ...
size_t count_mapper(size_t v);
size_t index_mapper(size_t v);
size_t pixe... 阅读全帖 |
|
k*******8 发帖数: 1304 | 8 ☆─────────────────────────────────────☆
sioc (煎饼爱果子) 于 (Thu Nov 15 19:48:20 2012, 美东) 提到:
发信人: BCBill (Bill), 信区: FleaMarket
标 题: 【陪审团请进】Hamshan78和记纠纷最新进展
发信站: BBS 未名空间站 (Thu Nov 15 19:36:15 2012, 美东)
今天中午中部时间2点,确定经理在场的情况下,我和hamshan78一起到了S Canal的
FedEx,另一著名ID也在现场。
实在是太忙了,刚刚开完组会,现在才来update,sorry for late.
长话短说
经过经理的确认,当时的情况是,10.4当天晚上,包裹没有被pick up,第二天10.5在一
个角落发现。
然后hamshan78填写了第二张label,经理pull出了和记的FedEx账号,因此最终charge了
和记的账户。因为hamshan78填写了40,000的保额,因此被要求当场开箱,并重新打包。
经理并未许诺free label,而是free for ... 阅读全帖 |
|
e********r 发帖数: 2352 | 9 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
3 books
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above ar... 阅读全帖 |
|
c**********e 发帖数: 2007 | 10 The answer is c) namespace.
This is the purpose of namespaces. They provide logical groupings of
identifiers. The result of using a namespace is similar to what could be
accomplished using a class with all static members. However, unlike a class
, a namespace can be reopened to include additional identifiers.
a) class
This is incorrect. Much more than a logical grouping of names is provided by
"class." See other comments.
b) extern |
|
w*l 发帖数: 2550 | 11 How about this?
谎言之九:普兹泰的小白鼠实验结论不成立
【普兹太在电视上宣布他的实验结论的时候,他实际上还没有完成全部实验。按照
科学界的惯例,他应该在完成实验之后,写成论文,经过同行审稿通过,在学术刊物上
发表论文,然后才向大众媒体宣布他的发现。普兹太所在的研究所的领导见他违背学术
规范,向公众提前公布未成熟的实验结果,引起不必要的恐慌,觉得他败坏了研究所的
名声,决定给他处以停职的处罚,后来又强迫他退休。普兹太当时已经68岁,本来也该
退休了,但是在这种情况下强迫他退休,就很容易让人联想到是因为他发表了不同的学
术观点而受到迫害。普兹太从此被反对转基因的人士当成了敢于反抗黑暗的科学界的英
雄人物。
普兹太的实验存在的问题包括:试验的动物太少,不足以得出有统计意义的结果;缺乏
合适的空白对照,以及用于喂养老鼠的膳食营养结构不平衡,后者也可能导致观察到的
病变。我们做实验应该有一个对照,一模一样的两组老鼠,一组喂转基因土豆,一组喂
同一品种的非转基因土豆,结果再来比较,看看有什么差异才能说明问题。而他并没有
用同一品种的土豆做对照,用的是另一品种的土豆。两种土豆的... 阅读全帖 |
|
c********2 发帖数: 56 | 12 面的是Associate C++ Developer,下面是面试题,光顾着记题了,最后只有56%的通过
率,要到
80%才能ONSITE,算是帮大家做点贡献吧,他家在招人,赶快去投简历
1) #include
using namespace std;
struct A{
A(int value) : m_value(value){}
int m_value;
};
struct B:A {
B(int value):A(value){}
};
int main(){
try {
try{
throw B(5);
}
catch(A a){
a.m_value *=2;
throw;
}
catch(B b){
b.m_value -=2;
throw b;
}
}
catch(A a){
... 阅读全帖 |
|
j******s 发帖数: 48 | 13 好吧,自己回答一下思路,虚心求各路大神拍,给点意见
第一题应该是建立一个binary tree,然后recursive求每一个节点的左右子树的最高高
度,他们和就是在这一位上的largest distance,可以online做,但是需要在每个节点
保存左右子树的高度并且动态更新。
o(n) time + O(n) space
第二题,
Assumption:
1 Log file is typically very small, operations are append, delete and read.
2 Cluster is built on Hadoop, which has a chunk size of 64MB, roughly, and
it might be too large and inefficient if we use this chunk size for the log
file.
3 Log information is typically not very important, less effort is needed for
redundan... 阅读全帖 |
|
t*****h 发帖数: 137 | 14 I haven't finished reading your code. But from the very beginning, you're
using namespace std.
My understanding is never using namespace std in the header, any other
classes use your class will have the namespace contamination.
#pragma once is also non standard.
修改
最后一行
static const int _scale = sizeof(ROMON_SCALE)/sizeof(int);
我们一般都把测试分开,这样可以用flag关掉测试,最后release的时候会比较小点。 |
|
f**********e 发帖数: 288 | 15
<%@ Page language="C#" %>
<%@ Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
|
|