Differences Between Java and CC++

Laborator
10/10 (2 voturi)
Domeniu: Calculatoare
Conține 1 fișier: doc
Pagini : 4 în total
Cuvinte : 1628
Mărime: 6.61KB (arhivat)
Publicat de: Theodor Marginean
Puncte necesare: 0

Extras din laborator

The Preprocessor

All C/C++ compilers implement a stage of compilation known as the preprocessor. The C++ preprocessor basically performs an intelligent search and replace on identifiers that have been declared using the #define or #typedef directives. Although most advocators of C++ discourage use of the preprocessor, which was inherited from C, it is still widely used by most C++ programmers. Most of the processor definitions in C++ are stored in header files, which complement the actual source code files.

The problem with the preprocessor approach is that it provides an easy way for programmers to inadvertently add unnecessary complexity to a program. What happens is that many programmers using the #define and #typedef directives end up inventing their own sublanguage within the confines of a particular project. This results in other programmers having to go through the header files and sort out all the #define and #typedef information to understand a program, which makes code maintenance and reuse almost impossible. An additional problem with the preprocessor approach is that it is weak when it comes to type checking and validation.

Java does not have a preprocessor. It provides similar functionality (#define, #typedef, and so on) to that provided by the C++ preprocessor, but with far more control. Constant data members are used in place of the #define directive, and class definitions are used in lieu of the #typedef directive. The result is that Java source code is much more consistent and easier to read than C++ source code. Additionally, Java programs don’t use header files; the Java compiler builds class definitions directly from the source code files, which contain both class definitions and method implementations.

Pointers

Most developers agree that the misuse of pointers causes the majority of bugs in C/C++ programming. Put simply, when you have pointers, you have the ability to trash memory. C++ programmers regularly use complex pointer arithmetic to create and maintain dynamic data structures. In return, C++ programmers spend a lot of time hunting down complex bugs caused by their complex pointer arithmetic.

The Java language does not support pointers. Java provides similar functionality by making heavy use of references. Java passes all arrays and objects by reference. This approach prevents common errors due to pointer mismanagement. It also makes programming easier in a lot of ways simply because the correct usage of pointers is easily misunderstood by all but the most seasoned programmers.

You may be thinking that the lack of pointers in Java will keep you from being able to implement many data structures, such as dynamic arrays. The reality is that any pointer task can be carried out just as easily and more reliably with objects and arrays of objects. You then benefit from the security provided by the Java runtime system; it performs boundary checking on all array indexing operations.

Structures and Unions

There are three types of complex data types in C++: classes, structures, and unions. Java only implements one of these data types: classes. Java forces programmers to use classes when the functionality of structures and unions is desired. Although this sounds like more work for the programmer, it actually ends up being more consistent, because classes can imitate structures and unions with ease. The Java designers really wanted to keep the language simple, so it only made sense to eliminate aspects of the language that overlapped.

Preview document

Differences Between Java and CC++ - Pagina 1
Differences Between Java and CC++ - Pagina 2
Differences Between Java and CC++ - Pagina 3
Differences Between Java and CC++ - Pagina 4

Conținut arhivă zip

  • Differences between Java and CC++.doc

Alții au mai descărcat și

Liste Dublu Înlănțuite Reprezentare cu Variabile Dinamice

/* Declaratii */ #ifndef LISTDINL_V1 #define LISTDINL_V1 #define INS_BEG 0 #define INS_END 1 #define ASC_ORD 2 #define DESC_ORD 3 #define NO_DUP...

Liste

3.1.1 Operatii fundamentale /* Declaratii */ typedef int INFO; typedef int NODEPTR, LISTA, POZITIE, BOOL; typedef struct nod { INFO info;...

Baze de Date

Clasif. utilizatorilor unor BD 1) utiliz. obisnuiti 2) utiliz. programatori de aplicatii 3) administrator de baza de date 4) administrator a...

Baze de date C6

2.Nivelul logic al BD Avem de-a face cu scheme conceptuale formeaza un model unitar al unei aplicatii complexe prin reunirea subschemelor...

Componente TCP IP

Fragmentare si defragmentare: Daca transfera pe o retea ETHERNET nu trebuie sa avem pachete mai mari de 1500 de octeti. IP poate cere un pachet...

Gestiunea adreselor pe Internet

Mecanismul de adresare ce servere pe domenii Forma: nume intercalate cu puncte. Cu cât numele sunt mai la dreapta, cu atât ierarhic e mai mare....

Intranet

Intranetul e o aplicatie a tehnologiei Internet intr-o organizatie de sine statatoare. Leaga resursele informatice interne si creaza un mecanism...

Magistrala AT si XT

BRIDGE PCI/PCI Exista 2 dialoguri. Legatura se face pe mai multe ramuri ale arhitecturii. Exista un BUS initiator (masterul) si un BUS tinta....

Te-ar putea interesa și

Sisteme cu Control Distribuit

If you are designing a client-server system you may also have to design a communication protocol between the client and the server. Of course,...

Tehnologii Web

1 - WEB AND ITS TECHNOLOGIES 1.1 the web and its beginnings The internet may be defined as the worldwide system of interconnected computer and...

Ai nevoie de altceva?