what is the usefulness of using assembly in c++? speed?
thanks
Printable View
what is the usefulness of using assembly in c++? speed?
thanks
Speed, confusion (to the un-initiated =), the ability to look cool, the best way to destroy code portability... Lots of reasons =).
Z.
I gotta say, im kinda tired of these kind of questions.
You should not learn assembly in conjunction with C++, it's already a mess as it is. If you want to look cool go ahead, but if you want any results, stay away from assembly.
ok i will follow then... =) sorry chimpface, i just wanted to know
Ther will forever be questions that will be answered over and over. "C++, or Java?", "D3D or OGL?", "Is there really a God?"... Nothing will do except to swallow an angry RTFM, and answer.
Z.
PS: no offense, Amon Ra, just observing the kind of posts that I have seen in other places =).
There's no good answer for everyone, only an answer for someone, so althought it looks like the same question, it depends on who asks it. I gotta say that i've been answering same questions in different ways as I start to think in new ways, good thing about learning is that you'll become familiar with the subjectivity of all matters...
lol, wasn't really what I was going to say, but doesn't matter :p
how would you tell if someone used c++ or c? (besides the OOP stuff)?
could i get some good tuts for c? thanks
No classes, the lack of exceptions, an exclusive use of malloc, are all good clues as to whether a program is C, or C++.
Z.
Don't bother learning C before C++, just go straight into C++.
Learn OO programming techniques.
Learning C programming will make it harder to learn OO in C++.
ok.. thanks guys
Not totally. This is valid C code (not for much longer if the standard gets its act together!):Quote:
Originally posted by kedaman
OOP stuff, and Generic Stuff, exceptions as Zaei mentioned and new instead of malloc, C++ is backward compatible which allows C programmerse to program in C++, and just by experience you can show who's been using what.
Just try and compile that in a C++ compiler :DCode:#include <stdio.h>
#include <stdlib.h>
main() {
int *ptr = malloc(5 * sizeof(int));
for(int i = 0; i < 5; ++i) {
printf("%d", ptr[i]);
}
free(ptr);
return 0;
}
Even if you can't derive it from the not-using of classes and such, there are some things that will help you. Parksies code for example would be neither C nor C++ by the exact standards :). C++ standard does not allow this line:
int *ptr = malloc(5 * sizeof(int));
You need an explicit cast when casting a void* (as returned by malloc) to any other pointer type.
neither does it allow this line:
main()
Every function needs a defined return type, C just assumes int.
C standard does not allow this line:
for(int i = 0; i < 5; ++i)
variables may only be declared at the start of a block, that is, directly after an opening { bracket. You would have to write:
main()
{
int i;
// ...
for(i = 0; i < 5; ++i)
{
// variables may be declared here
// ...
}
}
Another thing:
typedef struct
{
// members:
int i, s, e;
} MYSTRUCT;
This will only appear in code that was made to work with C, so you don't have to write
struct MYSTRUCT st;
Exclusive use of /* such */ comments is also a sign of C code. (Although most C compilers now support // and the current C standard requires it).
That's all I can think of at the moment.