Answer the question
In order to leave comments, you need to log in
An instance of its class as a C++ field?
Good day,
I have been programming in C# for a long time, and I decided to try the pros. And they broke my head with such a seemingly simple concept as a class field. In C#, field = another class = another structure = base structure(byte,int,char...). But in C++ when writing
class MyClass1
{
public:
MyClass2 mc2;
..{пустой конструктор}
};
class MyClass2
{
public:
int A,B,C;
..{пустой конструктор}
};
Answer the question
In order to leave comments, you need to log in
Просто описание класса заканчивайте точкой с запятой. Сразу после }. Ну и ещё ссылки вперёд запрещены. Либо описывайте MyClass2 перед MyClass1, либо просто объявите его:
class MyClass2;
class MyClass1
{
public:
MyClass2 mc2;
..{пустой конструктор}
};
class MyClass2
{
public:
int A,B,C;
..{пустой конструктор}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question