Using void * as the equivalent of a C ++ Java object

I am trying to create a class containing std::vectorof void*. I was told that it void*is the equivalent of C ++ for Objectin Java. Since this is a C ++ port for a program written in Java, it should work theoretically.

Java:

ArrayList<Object> list;

C ++:

vector<void*> list;

This will not compile, indicating an error: "Link: illegal use of the" void "type.

Is it void*really the equivalent of C ++ Java Object? Am I using this incorrectly?

+4
source share
4 answers

Java Object - , Java.

++ . , MyBaseClass ( ), .

, vector<void*>, . MyBaseClass, vector<MyBaseClass*>.

+6

, , , . , , , , . hokey, . , , .

+3

.

  • void* ++ Object.
    ++ .
  • , .

- , , , .

+1
  • void* vs Object. , , , void* ( ), Object , Object ( , ).

    , , , , , ++ , void*, . , .

  • , , , , void* Object.

+1
source

Source: https://habr.com/ru/post/1613116/


All Articles