I want a statement that does nothing but can be used in places requiring a statement. Pass: http://docs.python.org/release/2.5.2/ref/pass.html
Edit: Just saw: How does one execute a no-op in C/C++?
#define pass (void)0
Solved my problem. Thanks!
Parameters in C functions There are two ways to pass parameters in C: Pass by Value, Pass by Reference.
and class C: pass. becomes class C {};
No, you just use an empty block like: void function(int parameter) {
In C++ you can use std::find to determine whether or not an item is contained in a std::vector .
A null statement (just Semicolon), or empty brackets should work for you
For example Python's
while some_condition(): # presumably one that eventually turns false pass
Could translate to the following C++
while (/* some condition */) ;
Or
while (/* some condition */) {}
Perhaps for the ternary operator case, you could do:
x > y ? do_something() : true;
No. You don't have pass
or equivalent keyword. But you can write equivalent code without any such keyword.
def f(): pass
becomes
void f() {}
and
class C: pass
becomes
class C {};
In different context, different syntax could be useful. For example,
class MyError(Exception): pass
becomes
class MyError : public std::exception { using std::exception::exception; //inherits constructor! };
As you can see, in this context, you've to write using
to inherits constructors from the base class. In Python, pass
does the similar thing, in similar context.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With