std::string > C-string (const char* str, char str[]) |
Okay, assuming I agreed with that definition of "calculation", C++ doesn't make it easier than a string library would.
I think in C typecasts make more sense: volatile char* str = (volatile char*) number vs volatile char* str = volatile char*(number). |
Hahahahah! Ah... Both are the same cast using a different syntax.
A cast is a unary operator and there's two versions:
'(' type ')' expression
type expression
(I'm not sure, but both version may actually be condensed into "type_expression expression")
Being an operator, it has precedence. Sometimes you'll want to surround the expression in parentheses to make sure the compiler knows exactly which expression you're trying to cast. That's why it's not unusual to see a cast as T(x), rather than (T)x.
Could someone tell me whether this:
struct myStruct* myStruct_object;
myStruct_object->myVariable;
is any faster than
struct myStruct myStruct_object;
myStruct_object.myVariable;
? |
The latter is faster because it just accesses the stack. The former first accesses the stack, then dereferences a pointer.
These are equivalent:
1 2
|
struct{int a,b,c;} a;
a.a=0;
|
There's a lot of debate about which version is faster after compiler optimizations. There's no clear answer.
It doesn't need classes because it has structures, unions and enumerations. It needs them because it they're incredibly useful. Unions, for example, are very memory-efficient. But it doesn't need classes. In C++ there's no difference between the two. In C; structs cannot contain functions. But they can contain pointers to functions; so it isn't really important. |
Or maybe, just maybe, it doesn't need classes because it's not OO.