I
I
Ilia Zhitenev2016-02-05 15:03:22
OOP
Ilia Zhitenev, 2016-02-05 15:03:22

How to make a class prototype?

Hello. There are 2 classes.
The first class contains a vector that stores references to objects of the second class type.
And the second class is inherited from the first.
How to implement the definitions of these classes? Because always a class that is defined earlier swears that it does not know the second and the program fails to compile. How to be?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
AtomKrieg, 2016-02-05
@ilyazh

class Class2;

class Class1 {
std::vector<Class2*> v;
}

class Class2 : public Class1{
//...
}

S
Stanislav Makarov, 2016-02-05
@Nipheris

https://en.wikipedia.org/wiki/%D0%9F%D1%80%D0%B5%D...
en.stackoverflow.com/questions/41844/%D0%97%D0%B0%.. .

P
Peter, 2016-02-05
@petermzg

Write like this for one of the classes.
And then the full definition.

S
sitev_ru, 2016-02-05
@sitev_ru

If you didn’t know how to do it, how could you indicate the “class prototype” in the question?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question