由买买提看人间百态

topics

全部话题 - 话题: foo
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
S**Y
发帖数: 136
1
question 1:
template
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo { };
FooDerived fd;
What is preventing the above code from being legal C++?
A. FooDerived is a non-template class that derives from a template class.
B. tVar is a variable of an unknown type.
C. A constructor must be provided in FooDerived.
D. FooDerived uses the non-C++ type std::string.
E. The initialization of tVar occurs outside the body of Foo's const
s******t
发帖数: 2374
2
来自主题: JobHunting版 - Facebook phone screen
两个方法可以这么做么?如果A和B是disjoint的set的话。
=============递归:
int a[];
int b[];
if(a.length==0||b.length==0) return;
foo(a,0, b, 0);
void foo(int a[],int i, int b[], int j){
System.out.print(a[i]);
System.out.println(b[j] + ',');
if(++j >= b.length) {
i++;
j = 0;
}
if(i >= a.length) return;
foo(a, i, b, j);
}
============非递归
void foo(int a[], int b[]){
for(int i=0; i< a.length; i++){
for(int j=0; j< b.length; j++){
System.out.print(a[i]);
System.
c*****o
发帖数: 178
3
来自主题: JobHunting版 - Interview questions, Bloomberg
第3题可不可以用global variable呢?
int* input;
static void Foo(int);
int _tmain(int argc, _TCHAR* argv[])
{
int size = 100;
try{
Foo(size);
::free(input);
cout<<"free memory in Main function"< }
catch(exception &e){
cout< }
return 0;
}
void Foo(int size){
try{
input = (int*)(::malloc(size));
cout<<"allocate " < }
catch(exception &e){
cout<
f****4
发帖数: 1359
4
* C VS C++
* new expression
-operator new, new_hanlder
* Polymorphism
-virtual function
-is this program compile right? run right?
class A{
public: virtual void foo(){}
};
class B:public A{};
int main(){
B b;
b.foo();
}
[我开始说2个都是right,他连问3次"Are you sure?";第三次问的时候,我改了说,compile right, run wrong。但是,后面越想越不对,我返回去说这道题目,2个都是right,很sure]
-how is virtual table is constructed
-running time, how can a call to find the right virtual function
-下面这个设计有啥不好
class A{
public: virtual void foo(){}
virtual void foo
p**********s
发帖数: 115
5
来自主题: JobHunting版 - 回馈本版,贴ms onsite面经
我来解typedef那题:
#include
using namespace std;
void staticFun(int num) {
cout << "static function" << endl;
}
class foo{
public:
void classFun(int num) {
cout << "function in a class" << endl;
}
};
typedef void (*myStaticFun) (int);
typedef void (foo::*myClassFun) (int);
int main()
{
myStaticFun testStaticFun = staticFun;
testStaticFun(6);
foo foo1;
myClassFun testClassFun = &foo::classFun;
(foo1.*testClassFun)(6);
return 0;
}
a****n
发帖数: 1887
6
来自主题: JobHunting版 - C++问题3
写几个被问过的
1.
i = 0;
j = 0;
printf(i+++j);
printf(i);
printf(j);
2.
void foo(int x, int y, int z)
{
printf (x);
printf (y);
printf (z);
}
i = 0;
foo(++i, i++, ++i);
sequence point另外怎么确定编译器计算的顺序
3.
class A;//forward declaration
auto_ptr a;
有没有问题?
foo(new A(), new A())有啥问题?
foo(auto_ptr
(new A()), auto_ptr(new A()))有无问题?
auto_ptr 那些场合不能用
h*****g
发帖数: 312
7
来自主题: JobHunting版 - C++ online Test 一题
template
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo { };
FooDerived fd;
What is preventing the above code from being legal C++?
A.
The initialization of tVar occurs outside the body of Foo's constructor.
B.
FooDerived uses the non-C++ type std::string.
C.
tVar is a variable of an unknown type.
D.
FooDerived is a non-template class that derives from a template class.
E.
A constructor must be provided in FooDerived.
为啥E 是正确的呢?
s**x
发帖数: 7506
8
来自主题: JobHunting版 - 面试题
1)OO 设计题,简单化的21点,两个 player, A 算一点或 11 点。
搞砸了,focus too much on class design instead of computation.
2) google search hint problem, how to store.
not sure the standard answer, 不过可能偶算可以。
3) key/value pair + LRU caching problem, 问什么样的数据结构。
偶给了hash+double linked list, 然后人家问多线程怎么办,就傻眼了。
4) c++ question,
Foo *p = (Foo *)malloc(sizeof(Foo));
p->Foo();
can you do things like this? he insists it is correct, I said you have to use placement new. :(
s***c
发帖数: 50
9
来自主题: JobHunting版 - G家onsite面经
刚从G家onsite归来。新鲜面经奉上。
总共5轮,4轮technical interview, 一个thesis discussion。在technical里,有编
程题,有open design。我记得的问题有:
1. 编程题:一堆字符串。找longest common prefix。
我的方法就是找最短的字符串,对它的每个字符,逐个与其他字符串对应位置比较。(
求更好方法)
2. open question: 一堆文件,size差别极大( from KB to many GB). 找出所有内
容相同的文件。
3. 编程题: 有一个observer 类,监视另一个类foo 的成员变量的值,每当那个值被
修改,就要调用 该observer.updated() 方法。需要实现 foo.registerObserver(ob)
, foo.unregisterObserver( ob ), foo.changeValue( newvalue ). 要考虑thread
safe.
就是在register时把所有observer 链接到一个list里。在changeValue... 阅读全帖
g*********e
发帖数: 14401
10
来自主题: JobHunting版 - google电面杯具,贡献题目

the problem allows you to go from chat->chart,
by using a trie, you can only add new chars at the tail.
I think the traditional approach would be to use recursion.
If you want to see whether a string is decomposable,
bool foo(string){
return foo(tring) | foo(sring) | foo(sting) | ....
}
Doing this for one string would take O(n), the total runtime is O(n2)
But there should be much faster ways
g*********e
发帖数: 14401
11
来自主题: JobHunting版 - google电面杯具,贡献题目

the problem allows you to go from chat->chart,
by using a trie, you can only add new chars at the tail.
I think the traditional approach would be to use recursion.
If you want to see whether a string is decomposable,
bool foo(string){
return foo(tring) | foo(sring) | foo(sting) | ....
}
Doing this for one string would take O(n), the total runtime is O(n2)
But there should be much faster ways
S**I
发帖数: 15689
12
来自主题: JobHunting版 - [合集] G家onsite面经
☆─────────────────────────────────────☆
sharc (sharc) 于 (Mon Aug 22 15:15:14 2011, 美东) 提到:
刚从G家onsite归来。新鲜面经奉上。
总共5轮,4轮technical interview, 一个thesis discussion。在technical里,有编
程题,有open design。我记得的问题有:
1. 编程题:一堆字符串。找longest common prefix。
我的方法就是找最短的字符串,对它的每个字符,逐个与其他字符串对应位置比较。(
求更好方法)
2. open question: 一堆文件,size差别极大( from KB to many GB). 找出所有内
容相同的文件。
3. 编程题: 有一个observer 类,监视另一个类foo 的成员变量的值,每当那个值被
修改,就要调用 该observer.updated() 方法。需要实现 foo.registerObserver(ob)
, foo.unregisterObserver( ob )... 阅读全帖
s*****1
发帖数: 134
13
来自主题: JobHunting版 - NeAp 面试题一道
title公司少了两个字母,自己猜~
onsite, 太郁闷了,总共三轮面试,两轮烙印,没有coding,就是关于C++/Java等犄角
旮旯的问题,感觉就是要fail 我。现有一道我实在做不出,就猜了,大家看看吧:
C++的。假设父类有一个method叫foo(没有virtual),子类有一个method,override了
那个foo. 然后子类指针(注意是子类指针),指向父类空间,然后call 那个foo,调用
的是父类还是子类的foo?
我的回答是子类指针到父类需要cast的,而且也没一定可以行啊。他说假设可以,
然后我就猜了个子类的,其实我也不知道,回来一想可能是父类的,因为cast成功了。
然后他们看到我简历上写着C#,就问了个C#的术语,神马是Box 和 UnBox. 晕~
供参考,就当积攒RP吧~
n********r
发帖数: 719
14
来自主题: JobHunting版 - 问一下关于recursive算法的一般规律
假设有一个recursive function void foo
void foo(par){
...
foo(a);
...
}
谁能总结一下什么样的内容应该放在这里foo(a)语句之前, 什么应该放在之后?
至少终止条件肯定是放在前面的
b****g
发帖数: 192
15
来自主题: JobHunting版 - 问几个面试题
全是C++的
1. STL map怎么插入和查找才能让时间复杂度小于O(lg n)?
2. new和malloc后会发生什么?我回答就是分块内存也在前面存着大小
3. foo *p1 = new foo();
foo *p2 = new foo();
如果第一行成功了,第二行产生了exception,那么p1会怎么样?
4. smart pointer怎么用?
5. C++中怎么实现exception handle?
n**********2
发帖数: 214
16
来自主题: JobHunting版 - IPSoft的面试题,和大家共享下
很简单,呵呵。写一个函数的具体实现。
/**
* Given a list of objects, returns the last object in the list that is an
instance of type Foo.
* @param stuff the list of objects
* @return an object of type Foo
* @throws NoSuchFooException if there is no Foo in the list
*/
Foo getLastFoo(List stuff) throws NoSuchFooException;
m******e
发帖数: 82
17
来自主题: JobHunting版 - Facebook面经
第一题定义没错,编译可以通过,但是这样调用会出现不同结果
B* b = new B();
A* a = b;
B c;
a->foo(c); // 调用A的foo
b->foo(c); // 调用B的foo
i**d
发帖数: 357
18
emplace create the object inplace for you to save copy. insert is to copy
the existing one (or move)
struct Foo
{
Foo(int n, double x);
};
std::vector v;
v.emplace(someIterator, 42, 3.1416);
v.insert(someIterator, Foo(42, 3.1416));

发帖数: 1
19
来自主题: JobHunting版 - Leetcode第30题真心不容易
叔我来啦!
这道题就是说你先查一下words里每个单词的个数。注意每个单词都是等长的。
然后遍历字符串 像拿一根格尺,挨个比量一下,就可以了。
比如说:从 "barfoothefoobarman" 里找 ["foo", "bar"] 的链接
你先查一下,得到["foo": 1个, “bar” 1个]
然后遍历字符串
"barfoothefoobarman"
i
j
从i开始 截取3个字符是bar 然后你就 只需要再找["foo" 1个]
"barfoothefoobarman"
i
j
从j开始 截取3个是foo 然后就都找全了,可以把 i 放入结果里。
然后以每个i为开头的时候,都需要一个新的查数的表。
代码如下:
class Solution {
public List findSubstring(String s, String[] words) {
List res = new ArrayList<>();
int n = words.length, len = words[0].... 阅读全帖
a****r
发帖数: 154
20
来自主题: Football版 - MFL第一阶段盘点(西区)
西区第一阶段成绩:
foo: 4-1
E-girls: 4-1
alomar: 3-2
Maple: 1-4
本区四位同学同获第一阶段“死亡之组-但不是因为有中国队存在才死亡的"奖。第一
阶段取得了对other division 8-4的成绩。希望能够实现我的关于在本division出现
两支外卡队的语言。
e-girls是自始至终的大热,虽然在本division火并中输给foo一场。但是恐怖的是
其3大超级主力,McNabb, Curtis Martin, Shawn Alexander都歇完了bye week.
电钮队在第2阶段一举clinch playoff 席位也不是不可能发生的。
foo同学高举manning(peyton牌)就是一切的旗号占据小组榜首。根据我俩每周一块
看球的感觉,manning is getting better and better (hard to believe). foo
同学获第一阶段专吃大户奖。
我自己的队很受伤病的影响。打成这个成绩,扪心自问应该算幸运的了。
Maple同学的第2阶段相当关键,make it or break it. 在此一举
m*********s
发帖数: 354
21
来自主题: Football版 - MFL 2010 Playoff week 1
Playoff week 1 result
BG Red Stars(140.00) vs Teamster(84.00)
Eddy(110.00) vs Monster(83.00)
Datang(89.00) vs blackshop(66.00)
foo(101.00) vs dango (57.00)
蛋糕妹妹一赛季的鸿运被foo给终结了。
伏妹妹的第二个饭大喜交出了不错的成绩。
黑店和爱帝俺都搞不清是怎么回事。
一向豪言壮语的大唐和甜蔗一个天上一个地下。
本赛季最大的歪咛王非foo莫数。
拉丝继续着饭大喜的神话,连白神都惊呼"拉丝太猛了!"
对俺们其他人来说,就一句话:"酱油到底还要打多久呢?"
Playoff week 2
Ras vs foo
Eddy vs Datang
b**j
发帖数: 20742
22
来自主题: Football版 - MFL季后赛
4个小组第一
1. alderson (12-2)
2. juve (10-4)
3. redzone (9-5)
4. microcenter (6-8) <--- 我靠,这就是当年躺着进playoff的seahawks
外卡
5. francexplosn (9-5)
6. nj tea party (8-6) same div record as cake biting 3-3, head to head zli w
on so zli seeded at no. 6
7. cake biting (8-6)
最后一张外卡3个7-7的队伍brmj, leatherandwhip, foo
**updated**
tie breaker: divisional record brmj 3-3, leather 1-5, foo 2-4 (leather
eliminated)
2nd tiebreaker: total points scored. brmj 1121 > foo 1078 (foo eliminated)
c*****t
发帖数: 1879
23

你是指
select foo ();
工作,还是
insert table values (foo ());
工作,还是
update table set col = foo () where col = ...;
工作?
stored procedure 没写好的话,是可以出现前两个“工作”,但是到 update
的时候出问题的情形。比如,foo () 的结果是一 complex data structure,
这个 data structure 可能写的人没注意,只是 memory resident 的。但是
存到硬盘的结够必须是另外一种形式(比如 size header 等),因为有些
database 出于 performance 的考虑,所有的 in-memory data structure
得和硬盘 上的结构一一对应,并不提供 I/O wrapper 。这样的话,
in memory operation 是可以工作的。但是 store / load 在 database 里的
只是 memory pointer,没有实际的
x*****p
发帖数: 1707
24
Java is always pass by references. For primitive types, in Java 5, it is
considered as a object by autoboxing. Thus it is still pass by references.
The reason why the value of a primitive can not be changed outside the
function is because that the corresponding object of the primitive is
immutable.
Look at the following two examples.
1. void foo(String str) { str = "inFoo"; }
String s = "abc";
foo(s);
System.out.println(s);
The output is abc, not inFoo. String is an object, but it is im... 阅读全帖
g*****g
发帖数: 34805
25
来自主题: Java版 - 请教一个动态cast的问题
你要从头想,为啥要这个变量,不就是为了调用某个方法吗?
假设这个方法叫做blah。如果Foo可以blah,那blah就应该
在Foo里声明,没有这个问题。如果Foo不能blah,Bar可以,
当初接口为啥要传Foo进来呢,传Bar不好吗?
这不是反射能不能实现的问题,但凡碰到类似的地方,先考虑
重构。除非是第三方代码,没法动。
w***g
发帖数: 5958
26
【 以下文字转载自 Programming 讨论区 】
发信人: wdong (cybra), 信区: Programming
标 题: Makefile中怎么处理没有扩展名的文件?
发信站: BBS 未名空间站 (Wed Sep 23 15:21:13 2009, 美东)
比如foo.cpp生成foo.o,我可以写下面这样的rule:
.cpp.o:
$(CXX) -c -o $@ $^
但是从foo.o生成foo就不知道怎么写了。 gmake默认的rule应该类似
$(CC) -o $@ $^
怎么样才能把这个替换成我自己的rule呢?
t****t
发帖数: 6806
27
来自主题: Programming版 - C++ question
it happens that these temp objects are rvalues, so it's const.
it's not often to write like cosnt B& rb=B(); but it's very normal in
function calls, like
void foo(const B& b);
int main()
{
foo(B());
}
if you declare foo as void foo(B&), the call will fail.
f********a
发帖数: 1109
28
【 以下文字转载自 JobHunting 讨论区 】
发信人: fololunsia (我心飞扬), 信区: JobHunting
标 题: 【讨论】问一道很简单的C++题。。。。
发信站: BBS 未名空间站 (Mon May 28 23:06:47 2007)
下面两个程序,为什么EX1可以编译,EX2不可以?
======EX 1=======
class Base{
public:
void foo() const{ }
};
class Derived: public Base{
public:
int foo() const{ return 1; }
};
======EX 2======
class Base{
public:
virtual void foo() const{ }
};
class Derived: public Base{
public:
int foo() const{ return 1; }
};
T***B
发帖数: 137
29
来自主题: Programming版 - An interesting C++ compile error
When I compile the following code with g++, I got following error:
g++ tt.cpp
tt.cpp: In static member function `static void Derived::test()':
tt.cpp:36: no matching function for call to `Derived::foo(int)'
tt.cpp:23: candidates are: virtual int Derived::foo(int, int)
Seems the compiler doesn't try to look for the foo with 2 paras in the base
class if there is one foo method available in derived class. Any reason
compiler chooses to do this this way. How to make this thing work (elegantly
)?
Tha
T******r
发帖数: 257
30
来自主题: Programming版 - C++小插曲
class B
{
public:
virtual void foo(){...};
...
};
class D : public B
{
private:
virtual void foo(){...};
...
};
B* p = new D();
p->foo();
偶然发现这样居然也行, D的foo被called.
i***h
发帖数: 12655
31
来自主题: Programming版 - question about shift
one more question about char
how to read numbers into char?
I did:
char s;
int foo;
cin >> foo;
s = foo;
Can this code be shorter? Can I get rid of the temporary foo variable?
thanks
k**f
发帖数: 372
32
来自主题: Programming版 - a question about CAST

tem
My understanding is that you are trying to cast an address to an integer to
a double, which is hardly correct.
If foo() expects an address to a double as its input, you need to declare an
intermediate variable, say x, of type double, initialized to the value of
temp, and then call foo() with the address of x: foo(&x). If foo modifies
its input, you can then assign x to temp (may loss fractional part, though).
J*****n
发帖数: 4859
33
来自主题: Programming版 - C++子类中调用父类指针的问题
class A
{
protected:
int foo;
};
class B: public A
{
public:
bool compare(A *p)
{
if foo==p->foo then
return true;
else
return false;
}
};
代码如上,编译说p--〉foo不能被调用。
书上说改为B *p就可以了,另外似乎改为A &p也行。
谁能解释一下其中的机理呢?
谢谢。
w***g
发帖数: 5958
34
来自主题: Programming版 - C code参数传递出错可能的原因
确认一下你的void foo (float m)是否在b.c里声明了,或者声明被include到b.c里了。
如果没有被声明,那么gcc会自动根据foo(1.0)产生一个声明,也就是 int foo (doubl
e), 然后1.0被当作double传进去了,然后被foo当作float接收,打印出来自然就不对
了。
建议你用-Wall重新编译系统,然后好好看看警告信息。说不定还有别的类似的bug你没
发现。
w***g
发帖数: 5958
35
比如foo.cpp生成foo.o,我可以写下面这样的rule:
.cpp.o:
$(CXX) -c -o $@ $^
但是从foo.o生成foo就不知道怎么写了。 gmake默认的rule应该类似
$(CC) -o $@ $^
怎么样才能把这个替换成我自己的rule呢?
S**Y
发帖数: 136
36
来自主题: Programming版 - find bugs of c++ codes
question 1:
template
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo { };
FooDerived fd;
What is preventing the above code from being legal C++?
A. FooDerived is a non-template class that derives from a template class.
B. tVar is a variable of an unknown type.
C. A constructor must be provided in FooDerived.
D. FooDerived uses the non-C++ type std::string.
E. The initialization of tVar occurs outside the body of Foo's constructor.
===
k****5
发帖数: 546
37
来自主题: Programming版 - c++ 奇怪问题
#include
using namespace std;
class A{
int a;
public:
void foo(){
cout << "foo in A" << a < }
};
int main(){
A * Ap;
Ap->foo();
return 0;
}
gcc 4.2.4 输出是 “foo in A1474660693",A后面这个东西每个机子不会一样,但应
该连着run几次不会变,貌
似Ap指到了内存里面A的prototype,这是gcc的行为,还是c++标准?
z****e
发帖数: 2024
38
来自主题: Programming版 - 看道c++题: brianbench
1. static_cast(FooBar2 f)
FooBar2 f; is a "statement", not a "variable".
if you need something should be like this:
const Foo& foo=static_cast(FooBar2());
i guess hhxk18 means the above.
N***m
发帖数: 4460
39
来自主题: Programming版 - What does int & mean? C/C++ question
well, it is sth like:
int foo()
{
return 1;
}
int main()
{
int (*foo)(void)=::foo;
foo();
}
C*******h
发帖数: 60
40
来自主题: Programming版 - 问一个C++的问题
template
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo { };
FooDerived fd;
Why the code above NOT syntactically correct C++?
1) FooDerived uses the non-C++ type std::string.
2) FooDerived is a non-template class that derives from a template class.
3) The initialization of tVar occurs outside the body of Foo's constructor.
4)tVar is a variable of an unknown type.
5) A constructor must be provided in FooDerived.
从bb上看到的,谢谢!
s*****e
发帖数: 33
41
来自主题: Programming版 - What does the default constructor do?
Is there any difference between the following two implementations?
struct Foo
{
enum Enum
{
SIZE = 1024;
}

char m_buf[SIZE];
};
struct Foo
{
Foo()
{}
~Foo()
{}
enum Enum
{
SIZE = 1024;
}

char m_buf[SIZE];
};
You may get some surprise under gcc 3.4 or 4.1, see more detail:
http://streetprogrammer.blogspot.com/2011/12/default-constructo
y****n
发帖数: 15
42
多谢你的指点。
我按下面方式定义macro,用visual studio 2008编译。
但在实际执行add()时,执行的却是减法操作。
如果在add()和subtract()的最后加上"#undef OPER",则会出现编译错误,提示在foo
中找不到OPER的定义。
void add(...)
{
#define OPER +
foo(...)
}
void subtract(...)
{
#define OPER -
foo(...)
}
void foo(...)
{
...
v_out[pos1] = v_in[pos1] OPER v_in[pos2];
...
}

expression
t****t
发帖数: 6806
43
no, that's not how macro works. to use macro, you need to write:
define FOO \
{ \
/*...*/ \
v_out[pos1] = v_in[pos1] OPER v_in[pos2]; \
}
#define OPER +
void add(...)
FOO
#undef OPER
#define OPER -
void subtract(...)
FOO
#undef OPER
it's not a very pleasant solution, of course. i won't recommend that.

foo
N8
发帖数: 110
44
template

no, that's not how macro works. to use macro, you need to write:
define FOO \
{ \
/*...*/ \
v_out[pos1] = v_in[pos1] OPER v_in[pos2]; \
}
#define OPER +
void add(...)
FOO
#undef OPER
#define OPER -
void subtract(...)
FOO
#undef OPER
it's not a very pleasant solution, of course. i won't recommend that.
foo
d****i
发帖数: 4809
45
来自主题: Programming版 - 写惯了C++ code,再写C code真不习惯
呵呵,有些小细节是有点,比如说struct的声明
C++:
struct Foo
{
//some fields
};
void func(Foo *a)
{
}
C:
struct Foo
{
//some fields
};
void func(struct Foo *a)
{
}
每个前要加个struct实在有点太那个了,除非一开始就typedef一下。
d******i
发帖数: 7160
46
比如
class A{int i[MAX];virtual void foo(){};};
class B: virtual public A{void foo(){cout<<"B";}};
class C: virtual public A{void foo(){cout<<"C";}};
class D: public B,C;
好像这么一virtual继承,D的对象里就只有一份i[MAX]了吧?
但这问题只在multiple继承里才有吧?
还有,成员函数foo()的copy还得有好几份吧?还需通过::指明,对不?
谢谢!
N***r
发帖数: 2539
47

对于"git reset --soft"命令,若不加任何branch或者文件名,单独运行该命令是干什
么用的??
I guess 'git reset --soft' is invalid, you have to tell git how many commits
you want to rest 'softly', like, 'git reset --soft HEAD~1', which 'softly'
resets your last commit. When you do reset 'softly' and HEAD~1, the files
you modified and submitted in the last commit become 'modified but not
committed'. For example, in your last 'A5' commit, you modified one single
file 'src/foo.C', when you do 'git status' before you do reset, you wi... 阅读全帖
t****t
发帖数: 6806
48
no, i don't mean containers. for example, you want class Foo, instead of
Foo* f=new Foo;
you just say
Foo f;
the same rule extends to almost everywhere.
r**m
发帖数: 1825
49
来自主题: Programming版 - Javascript的Scope问题
这个就是javascript最SB的地方,明明是最初的设计者偷懒,现在吹成一朵花。
不能直觉地,清晰地看出变量的scope的语言,只会给developer带来无穷的麻烦。
看看下面的输出。
var foo = 1;
function bar() {
if (!foo) {
var foo = 10;
}
alert(foo);
}
bar();
再以个
var a = 1;
function b() {
a = 10;
return;
function a() {}
}
b();
alert(a);
这种SB语言居然有人捧臭脚,
m*********a
发帖数: 3299
50
来自主题: Programming版 - 这二个在C++中有区别不?
多谢。终于懂了。
真是太坑了,java 的实现多简单啊
Foo myFoo=new Foo();

c++的
Foo &myFoo=*(new Foo());
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)